Skip to content

Commit

Permalink
refactor(data-access): move v2 up
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Jan 10, 2025
1 parent 83fe82c commit d0fc79c
Show file tree
Hide file tree
Showing 155 changed files with 123 additions and 1,048 deletions.
938 changes: 4 additions & 934 deletions packages/spacecat-shared-data-access/src/index.d.ts
100644 → 100755

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/spacecat-shared-data-access/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
* governing permissions and limitations under the License.
*/

import { createDataAccess } from './v2/index.js';
import { createDataAccess } from './service/index.js';

export * from './service/index.js';

const TABLE_NAME_DATA = 'spacecat-services-data-dev';

Expand All @@ -31,5 +33,3 @@ export default function dataAccessWrapper(fn) {
return fn(request, context);
};
}

export * from './v2/index.js';
26 changes: 26 additions & 0 deletions packages/spacecat-shared-data-access/src/models/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

export type * from './audit';
export type * from './configuration';
export type * from './base';
export type * from './experiment';
export type * from './import-job';
export type * from './import-url';
export type * from './key-event';
export type * from './latest-audit';
export type * from './opportunity';
export type * from './organization';
export type * from './site';
export type * from './site-candidate';
export type * from './site-top-page';
export type * from './suggestion';
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
* governing permissions and limitations under the License.
*/

export type * from './errors/index.d.ts';
export type * from './models/index.d.ts';
export type * from './util/index.d.ts';
interface DataAccessConfig {
tableNameData: string;
}

export function createDataAccess(
config: DataAccessConfig,
logger: object,
): object;
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import AWSXray from 'aws-xray-sdk';
import { Service } from 'electrodb';

import { EntityRegistry } from './models/index.js';
import { EntityRegistry } from '../models/index.js';

export * from './errors/index.js';
export * from './models/index.js';
export * from './util/index.js';
export * from '../errors/index.js';
export * from '../models/index.js';
export * from '../util/index.js';

const createRawClient = (client = undefined) => {
const dbClient = client || AWSXray.captureAWSv3Client(new DynamoDB());
Expand Down
26 changes: 0 additions & 26 deletions packages/spacecat-shared-data-access/src/v2/models/index.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/util/util.js';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps, zeroPad } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps, zeroPad } from '../../../src/util/util.js';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeIdAndAuditFields } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields } from '../../../src/util/util.js';

use(chaiAsPromised);

Expand Down
2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/test/it/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { spawn } from 'dynamo-db-local';

import { sleep } from '../unit/v2/util.js';
import { sleep } from '../unit/util.js';

let dynamoDbLocalProcess = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';

import ImportJobModel from '../../../src/v2/models/import-job/import-job.model.js';
import ImportJobModel from '../../../src/models/import-job/import-job.model.js';
import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';

import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/util/util.js';
import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ValidationError } from '../../../src/index.js';
import fixtures from '../../fixtures/index.fixtures.js';
import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/util/util.js';

use(chaiAsPromised);
use(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';

import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/util/util.js';
import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeTimestamps } from '../../../src/util/util.js';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
import { sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeTimestamps } from '../../../src/util/util.js';

use(chaiAsPromised);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';

import siteFixtures from '../../fixtures/sites.fixture.js';
import { sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeTimestamps } from '../../../src/util/util.js';
import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import chaiAsPromised from 'chai-as-promised';
import { validate as uuidValidate } from 'uuid';

import { ValidationError } from '../../../src/index.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields, sanitizeTimestamps } from '../../../src/util/util.js';

import { getDataAccess } from '../util/db.js';
import { seedDatabase } from '../util/seed.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/test/it/util/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import { DynamoDB } from '@aws-sdk/client-dynamodb';

import { createDataAccess } from '../../../src/v2/index.js';
import { createDataAccess } from '../../../src/service/index.js';

export const TEST_DA_CONFIG = {
indexNameAllImportJobsByDateRange: 'spacecat-services-all-import-jobs-by-date-range',
Expand Down
2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/test/it/util/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import { idNameToEntityName } from '../../../src/v2/util/util.js';
import { idNameToEntityName } from '../../../src/util/util.js';
import fixtures from '../../fixtures/index.fixtures.js';

import { getDataAccess, getDynamoClients, TEST_DA_CONFIG } from './db.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/spacecat-shared-data-access/test/it/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
import { removeElectroProperties } from '../../../src/v2/util/util.js';
import { removeElectroProperties } from '../../../src/util/util.js';

const randomDate = (start, end) => {
if (start.getTime() >= end.getTime()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { expect, use as chaiUse } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';

import ApiKey from '../../../../../src/v2/models/api-key/api-key.model.js';
import ApiKey from '../../../../src/models/api-key/api-key.model.js';

import { createElectroMocks } from '../../util.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import { stub } from 'sinon';
import sinonChai from 'sinon-chai';

import ApiKey from '../../../../../src/v2/models/api-key/api-key.model.js';
import ApiKey from '../../../../src/models/api-key/api-key.model.js';
import { createElectroMocks } from '../../util.js';

chaiUse(chaiAsPromised);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';

import { stub } from 'sinon';
import Audit from '../../../../../src/v2/models/audit/audit.model.js';
import Audit from '../../../../src/models/audit/audit.model.js';

import { createElectroMocks } from '../../util.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import { stub } from 'sinon';
import sinonChai from 'sinon-chai';

import Audit from '../../../../../src/v2/models/audit/audit.model.js';
import Audit from '../../../../src/models/audit/audit.model.js';
import { createElectroMocks } from '../../util.js';

chaiUse(chaiAsPromised);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { ElectroValidationError } from 'electrodb';
import { spy, stub } from 'sinon';
import sinonChai from 'sinon-chai';

import BaseCollection from '../../../../../src/v2/models/base/base.collection.js';
import Schema from '../../../../../src/v2/models/base/schema.js';
import BaseModel from '../../../../../src/v2/models/base/base.model.js';
import { DataAccessError } from '../../../../../src/index.js';
import BaseCollection from '../../../../src/models/base/base.collection.js';
import Schema from '../../../../src/models/base/schema.js';
import BaseModel from '../../../../src/models/base/base.model.js';
import { DataAccessError } from '../../../../src/index.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import { Entity } from 'electrodb';
import { spy, stub } from 'sinon';
import sinonChai from 'sinon-chai';

import BaseModel from '../../../../../src/v2/models/base/base.model.js';
import KeyEventSchema from '../../../../../src/v2/models/key-event/key-event.schema.js';
import OpportunitySchema from '../../../../../src/v2/models/opportunity/opportunity.schema.js';
import SuggestionSchema from '../../../../../src/v2/models/suggestion/suggestion.schema.js';
import Reference from '../../../../../src/v2/models/base/reference.js';
import BaseCollection from '../../../../../src/v2/models/base/base.collection.js';
import BaseModel from '../../../../src/models/base/base.model.js';
import KeyEventSchema from '../../../../src/models/key-event/key-event.schema.js';
import OpportunitySchema from '../../../../src/models/opportunity/opportunity.schema.js';
import SuggestionSchema from '../../../../src/models/suggestion/suggestion.schema.js';
import Reference from '../../../../src/models/base/reference.js';
import BaseCollection from '../../../../src/models/base/base.collection.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { expect, use as chaiUse } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';

import EntityRegistry from '../../../../../src/v2/models/base/entity.registry.js';
import { BaseCollection, BaseModel, DataAccessError } from '../../../../../src/index.js';
import Schema from '../../../../../src/v2/models/base/schema.js';
import EntityRegistry from '../../../../src/models/base/entity.registry.js';
import { BaseCollection, BaseModel, DataAccessError } from '../../../../src/index.js';
import Schema from '../../../../src/models/base/schema.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import sinonChai from 'sinon-chai';

import { stub } from 'sinon';

import Reference from '../../../../../src/v2/models/base/reference.js';
import ReferenceError from '../../../../../src/v2/errors/reference.error.js';
import Reference from '../../../../src/models/base/reference.js';
import ReferenceError from '../../../../src/errors/reference.error.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';
import { validate as uuidValidate } from 'uuid';

import SchemaBuilder from '../../../../../src/v2/models/base/schema.builder.js';
import { BaseCollection, BaseModel, SchemaBuilderError } from '../../../../../src/index.js';
import SchemaBuilder from '../../../../src/models/base/schema.builder.js';
import { BaseCollection, BaseModel, SchemaBuilderError } from '../../../../src/index.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import { expect, use as chaiUse } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';

import { SchemaError, SchemaValidationError } from '../../../../../src/v2/errors/index.js';
import BaseModel from '../../../../../src/v2/models/base/base.model.js';
import BaseCollection from '../../../../../src/v2/models/base/base.collection.js';
import Schema from '../../../../../src/v2/models/base/schema.js';
import Reference from '../../../../../src/v2/models/base/reference.js';
import { SchemaError, SchemaValidationError } from '../../../../src/errors/index.js';
import BaseModel from '../../../../src/models/base/base.model.js';
import BaseCollection from '../../../../src/models/base/base.collection.js';
import Schema from '../../../../src/models/base/schema.js';
import Reference from '../../../../src/models/base/reference.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import { stub } from 'sinon';
import sinonChai from 'sinon-chai';

import Configuration from '../../../../../src/v2/models/configuration/configuration.model.js';
import Configuration from '../../../../src/models/configuration/configuration.model.js';

import { createElectroMocks } from '../../util.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import chaiAsPromised from 'chai-as-promised';
import { stub } from 'sinon';
import sinonChai from 'sinon-chai';

import Configuration from '../../../../../src/v2/models/configuration/configuration.model.js';
import configurationFixtures from '../../../../fixtures/configurations.fixture.js';
import Configuration from '../../../../src/models/configuration/configuration.model.js';
import configurationFixtures from '../../../fixtures/configurations.fixture.js';
import { createElectroMocks } from '../../util.js';
import { sanitizeIdAndAuditFields } from '../../../../../src/v2/util/util.js';
import { sanitizeIdAndAuditFields } from '../../../../src/util/util.js';

chaiUse(chaiAsPromised);
chaiUse(sinonChai);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { expect, use as chaiUse } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinonChai from 'sinon-chai';

import Experiment from '../../../../../src/v2/models/experiment/experiment.model.js';
import Experiment from '../../../../src/models/experiment/experiment.model.js';

import { createElectroMocks } from '../../util.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chaiAsPromised from 'chai-as-promised';
import { stub } from 'sinon';
import sinonChai from 'sinon-chai';

import Experiment from '../../../../../src/v2/models/experiment/experiment.model.js';
import Experiment from '../../../../src/models/experiment/experiment.model.js';
import { createElectroMocks } from '../../util.js';

chaiUse(chaiAsPromised);
Expand Down
Loading

0 comments on commit d0fc79c

Please sign in to comment.