@encodeagent/platform-helper-data 1.2510.1041539

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,39 @@
1
+ COMMERCIAL LICENSE AGREEMENT
2
+
3
+ Copyright (c) 2024 EncodeAgent Team. All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are the proprietary
6
+ and confidential information of EncodeAgent Team ("Confidential Information").
7
+
8
+ TERMS AND CONDITIONS:
9
+
10
+ 1. OWNERSHIP: The Software is owned by EncodeAgent Team and is protected by copyright
11
+ laws and international copyright treaties, as well as other intellectual property
12
+ laws and treaties.
13
+
14
+ 2. LICENSE GRANT: Subject to the terms of this Agreement, EncodeAgent Team grants you
15
+ a limited, non-exclusive, non-transferable license to use the Software solely for
16
+ internal business purposes within your organization.
17
+
18
+ 3. RESTRICTIONS: You may not:
19
+ - Copy, modify, or create derivative works of the Software
20
+ - Distribute, sell, lease, rent, or sublicense the Software
21
+ - Reverse engineer, decompile, or disassemble the Software
22
+ - Remove or alter any proprietary notices or labels on the Software
23
+
24
+ 4. CONFIDENTIALITY: You acknowledge that the Software contains trade secrets and
25
+ confidential information of EncodeAgent Team. You agree to maintain the
26
+ confidentiality of such information.
27
+
28
+ 5. TERMINATION: This license is effective until terminated. Your rights under this
29
+ license will terminate automatically without notice if you fail to comply with
30
+ any term(s) of this Agreement.
31
+
32
+ 6. DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
33
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
35
+
36
+ 7. LIMITATION OF LIABILITY: IN NO EVENT SHALL ENCODEAGENT TEAM BE LIABLE FOR ANY
37
+ CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
38
+
39
+ For licensing inquiries, contact: team@encodeagent.com
package/README.md ADDED
@@ -0,0 +1,202 @@
1
+ # @encodeagent/platform-helper-data
2
+
3
+ Comprehensive TypeScript data library for the EncodeAgent platform with database utilities, query builders, migrations, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @encodeagent/platform-helper-data
9
+ ```
10
+
11
+ ## Features
12
+
13
+ ### Database Connection Management
14
+ - **Connection utilities**: Connect, disconnect, and test database connections
15
+ - **Connection pooling**: Efficient connection pool management
16
+ - **Multi-database support**: Support for various database engines
17
+
18
+ ### Query Building
19
+ - **SQL Query Builder**: Programmatic SQL query construction
20
+ - **Type-safe queries**: TypeScript-first query building
21
+ - **Complex joins**: Support for complex JOIN operations
22
+ - **WHERE clause builder**: Flexible condition building
23
+
24
+ ### Schema Management
25
+ - **Table operations**: Create, alter, and drop tables
26
+ - **Index management**: Create and manage database indexes
27
+ - **Constraint handling**: Foreign keys, unique constraints, and checks
28
+ - **Schema validation**: Validate schema definitions
29
+
30
+ ### Migration System
31
+ - **Version control**: Database schema versioning
32
+ - **Migration runner**: Execute and rollback migrations
33
+ - **Migration generator**: Create new migration files
34
+ - **Status tracking**: Track migration execution status
35
+
36
+ ### Transaction Management
37
+ - **ACID transactions**: Full transaction support
38
+ - **Isolation levels**: Configurable transaction isolation
39
+ - **Transaction wrapper**: Execute functions within transactions
40
+ - **Rollback handling**: Automatic rollback on errors
41
+
42
+ ### Repository Pattern
43
+ - **Base repository**: Generic repository implementation
44
+ - **CRUD operations**: Standard create, read, update, delete operations
45
+ - **Query methods**: Flexible query methods
46
+ - **Type safety**: Full TypeScript support
47
+
48
+ ### Data Validation
49
+ - **Input validation**: Validate data before database operations
50
+ - **Constraint checking**: Verify database constraints
51
+ - **Data sanitization**: Clean and sanitize input data
52
+ - **Foreign key validation**: Ensure referential integrity
53
+
54
+ ### Performance Monitoring
55
+ - **Query logging**: Track query performance
56
+ - **Performance metrics**: Collect and analyze performance data
57
+ - **Query optimization**: Optimize slow queries
58
+ - **Performance analysis**: Comprehensive performance reporting
59
+
60
+ ### Backup & Recovery
61
+ - **Database backups**: Create full and incremental backups
62
+ - **Backup scheduling**: Automated backup scheduling
63
+ - **Restore operations**: Restore from backup files
64
+ - **Backup monitoring**: Track backup status and health
65
+
66
+ ## Usage Examples
67
+
68
+ ### Database Connection
69
+
70
+ ```typescript
71
+ import { connectDatabase, testDatabaseConnection } from '@encodeagent/platform-helper-data';
72
+
73
+ const config = {
74
+ host: 'localhost',
75
+ port: 5432,
76
+ database: 'myapp',
77
+ username: 'user',
78
+ password: 'password'
79
+ };
80
+
81
+ // Test connection
82
+ const isConnected = await testDatabaseConnection(config);
83
+
84
+ // Connect to database
85
+ const connection = await connectDatabase(config);
86
+ ```
87
+
88
+ ### Query Building
89
+
90
+ ```typescript
91
+ import { buildSelectQuery, buildWhereClause } from '@encodeagent/platform-helper-data';
92
+
93
+ const whereConditions = [
94
+ { field: 'status', operator: '=', value: 'active' },
95
+ { field: 'created_at', operator: '>', value: '2024-01-01', logic: 'AND' }
96
+ ];
97
+
98
+ const query = buildSelectQuery(
99
+ 'users',
100
+ ['id', 'name', 'email'],
101
+ whereConditions
102
+ );
103
+ ```
104
+
105
+ ### Repository Pattern
106
+
107
+ ```typescript
108
+ import { createRepository } from '@encodeagent/platform-helper-data';
109
+
110
+ interface User {
111
+ id: number;
112
+ name: string;
113
+ email: string;
114
+ }
115
+
116
+ const userRepository = createRepository<User>({
117
+ tableName: 'users',
118
+ primaryKey: 'id',
119
+ timestamps: true
120
+ });
121
+
122
+ // CRUD operations
123
+ const user = await userRepository.findById(1);
124
+ const users = await userRepository.findAll();
125
+ const newUser = await userRepository.create({ name: 'John', email: 'john@example.com' });
126
+ ```
127
+
128
+ ### Migrations
129
+
130
+ ```typescript
131
+ import { runMigrations, createMigration } from '@encodeagent/platform-helper-data';
132
+
133
+ const migrationConfig = {
134
+ migrationsPath: './migrations',
135
+ tableName: 'migrations'
136
+ };
137
+
138
+ // Run pending migrations
139
+ await runMigrations(migrationConfig);
140
+
141
+ // Create new migration
142
+ const migrationId = await createMigration('add_user_table', migrationConfig);
143
+ ```
144
+
145
+ ### Transactions
146
+
147
+ ```typescript
148
+ import { executeInTransaction } from '@encodeagent/platform-helper-data';
149
+
150
+ const result = await executeInTransaction(async (transaction) => {
151
+ // All operations within this function will be part of the transaction
152
+ const user = await userRepository.create({ name: 'John' });
153
+ const profile = await profileRepository.create({ userId: user.id });
154
+ return { user, profile };
155
+ });
156
+ ```
157
+
158
+ ## Type Definitions
159
+
160
+ The library provides comprehensive TypeScript type definitions for all database operations:
161
+
162
+ - `DatabaseConfig` - Database connection configuration
163
+ - `QueryResult<T>` - Query result with typed rows
164
+ - `SchemaDefinition` - Table schema definition
165
+ - `MigrationConfig` - Migration configuration
166
+ - `TransactionOptions` - Transaction settings
167
+ - `RepositoryOptions` - Repository configuration
168
+ - `ValidationRules` - Data validation rules
169
+ - `PerformanceMetrics` - Performance monitoring data
170
+
171
+ ## Requirements
172
+
173
+ - Node.js >= 20.0.0
174
+ - TypeScript >= 5.2.0
175
+
176
+ ## Development
177
+
178
+ ```bash
179
+ # Install dependencies
180
+ npm install
181
+
182
+ # Build the library
183
+ npm run build
184
+
185
+ # Run tests
186
+ npm test
187
+
188
+ # Run linting
189
+ npm run lint
190
+ ```
191
+
192
+ ## License
193
+
194
+ UNLICENSED - Proprietary software of PrimeObjects Software Inc.
195
+
196
+ ## Support
197
+
198
+ For support and questions, contact: encode.agent@primeobjects.com
199
+
200
+ ---
201
+
202
+ *Part of the EncodeAgent Platform ecosystem*
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @fileoverview AWS DynamoDB implementation
3
+ */
4
+ import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
5
+ /**
6
+ * Create AWS DynamoDB connection
7
+ * @param props Connection properties with URI and key
8
+ * @returns Promise<IConnectionResult>
9
+ */
10
+ export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
11
+ /**
12
+ * Retrieve document by ID from AWS DynamoDB
13
+ * @param props Retrieve properties with client, collection (table), and id
14
+ * @returns Promise<IRetrieveResult<T>>
15
+ */
16
+ export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aws-dynamodb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAM1H;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAmD3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAkCpG"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview AWS DynamoDB implementation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.connect = connect;
7
+ exports.retrieve = retrieve;
8
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
9
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
10
+ const ENGINE = "aws-dynamodb";
11
+ /**
12
+ * Create AWS DynamoDB connection
13
+ * @param props Connection properties with URI and key
14
+ * @returns Promise<IConnectionResult>
15
+ */
16
+ async function connect(props) {
17
+ try {
18
+ const { uri, key } = props;
19
+ if (!uri) {
20
+ return {
21
+ engine: "aws-dynamodb",
22
+ error: 'AWS DynamoDB URI is required'
23
+ };
24
+ }
25
+ if (!key) {
26
+ return {
27
+ engine: ENGINE,
28
+ error: 'AWS DynamoDB access key is required'
29
+ };
30
+ }
31
+ // Parse AWS credentials from key (format: accessKeyId:secretAccessKey)
32
+ const [accessKeyId, secretAccessKey] = key.split(':');
33
+ if (!accessKeyId || !secretAccessKey) {
34
+ return {
35
+ engine: ENGINE,
36
+ error: 'AWS key must be in format: accessKeyId:secretAccessKey'
37
+ };
38
+ }
39
+ // Create DynamoDB client configuration
40
+ const clientConfig = {
41
+ credentials: {
42
+ accessKeyId,
43
+ secretAccessKey
44
+ },
45
+ endpoint: uri.startsWith('http') ? uri : undefined
46
+ };
47
+ // Create AWS DynamoDB client
48
+ const client = new client_dynamodb_1.DynamoDBClient(clientConfig);
49
+ return {
50
+ engine: ENGINE,
51
+ client
52
+ };
53
+ }
54
+ catch (error) {
55
+ return {
56
+ engine: ENGINE,
57
+ error: error instanceof Error ? error.message : 'Failed to connect to AWS DynamoDB'
58
+ };
59
+ }
60
+ }
61
+ /**
62
+ * Retrieve document by ID from AWS DynamoDB
63
+ * @param props Retrieve properties with client, collection (table), and id
64
+ * @returns Promise<IRetrieveResult<T>>
65
+ */
66
+ async function retrieve(props) {
67
+ try {
68
+ const { client, id, containerId } = props;
69
+ // Create GetItem command
70
+ const command = new client_dynamodb_1.GetItemCommand({
71
+ TableName: containerId,
72
+ Key: (0, util_dynamodb_1.marshall)({ id })
73
+ });
74
+ // Execute the command
75
+ const response = await client.send(command);
76
+ if (!response.Item) {
77
+ return {
78
+ engine: ENGINE,
79
+ error: `Document with ID '${id}' not found in table '${containerId}'`
80
+ };
81
+ }
82
+ // Unmarshall the DynamoDB item to regular object
83
+ const data = (0, util_dynamodb_1.unmarshall)(response.Item);
84
+ return {
85
+ engine: ENGINE,
86
+ data
87
+ };
88
+ }
89
+ catch (error) {
90
+ return {
91
+ engine: ENGINE,
92
+ error: error instanceof Error ? error.message : 'Failed to retrieve document from DynamoDB'
93
+ };
94
+ }
95
+ }
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aws-dynamodb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAaH,0BA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AAC;AACL,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,QAAQ,CAAI,KAAqC;IACnE,IAAI,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;QAE1C,yBAAyB;QACzB,MAAM,OAAO,GAAG,IAAI,gCAAc,CAAC;YAC/B,SAAS,EAAE,WAAW;YACtB,GAAG,EAAE,IAAA,wBAAQ,EAAC,EAAE,EAAE,EAAE,CAAC;SACxB,CAAC,CAAC;QAEH,sBAAsB;QACtB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAE5C,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,WAAW,GAAG;aACxE,CAAC;QACN,CAAC;QAED,iDAAiD;QACjD,MAAM,IAAI,GAAG,IAAA,0BAAU,EAAC,QAAQ,CAAC,IAAI,CAAM,CAAC;QAE5C,OAAO;YACH,MAAM,EAAE,MAAM;YACd,IAAI;SACP,CAAC;IAEN,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2CAA2C;SAC9F,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @fileoverview Azure Cosmos DB implementation
3
+ */
4
+ import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
5
+ /**
6
+ * Create Azure Cosmos DB connection
7
+ * @param props Connection properties with URI and key
8
+ * @returns Promise<IConnectionResult>
9
+ */
10
+ export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
11
+ /**
12
+ * Retrieve document by ID from Azure Cosmos DB
13
+ * @param props Retrieve properties with client, collection (container), and id
14
+ * @returns Promise<IRetrieveResult<T>>
15
+ */
16
+ export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/azure-cosmosdb/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAyB1H;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgC3F;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAgDpG"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Azure Cosmos DB implementation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.connect = connect;
7
+ exports.retrieve = retrieve;
8
+ const platform_helper_util_1 = require("@encodeagent/platform-helper-util");
9
+ const cosmos_1 = require("@azure/cosmos");
10
+ const ENGINE = "azure-cosmosdb";
11
+ /**
12
+ * Create Azure Cosmos DB connection
13
+ * @param props Connection properties with URI and key
14
+ * @returns Promise<IConnectionResult>
15
+ */
16
+ async function connect(props) {
17
+ try {
18
+ const { uri, key } = props;
19
+ if (!uri) {
20
+ return {
21
+ engine: ENGINE,
22
+ error: 'Azure Cosmos DB URI is required'
23
+ };
24
+ }
25
+ if (!key) {
26
+ return {
27
+ engine: ENGINE,
28
+ error: 'Azure Cosmos DB key is required'
29
+ };
30
+ }
31
+ // Create Azure Cosmos DB client
32
+ const client = new cosmos_1.CosmosClient({ endpoint: uri, key });
33
+ return {
34
+ engine: ENGINE,
35
+ client
36
+ };
37
+ }
38
+ catch (error) {
39
+ return {
40
+ engine: ENGINE,
41
+ error: error instanceof Error ? error.message : 'Failed to connect to Azure Cosmos DB'
42
+ };
43
+ }
44
+ }
45
+ /**
46
+ * Retrieve document by ID from Azure Cosmos DB
47
+ * @param props Retrieve properties with client, collection (container), and id
48
+ * @returns Promise<IRetrieveResult<T>>
49
+ */
50
+ async function retrieve(props) {
51
+ try {
52
+ const { client, id, partitionKey, databaseId, containerId } = props;
53
+ // Get database and container references
54
+ const database = client.database(databaseId);
55
+ if (!databaseId) {
56
+ return {
57
+ engine: ENGINE,
58
+ error: 'The databaseId or process.env.DATABASE_ID is required'
59
+ };
60
+ }
61
+ const container = database.container(containerId);
62
+ if ((0, platform_helper_util_1.isNonEmptyString)(partitionKey)) {
63
+ const { resource: item } = await container.item(id, partitionKey).read();
64
+ return {
65
+ engine: ENGINE,
66
+ data: item
67
+ };
68
+ }
69
+ else {
70
+ const iterator = container.items.query({
71
+ query: "SELECT * FROM c WHERE c.id = @id",
72
+ parameters: [{ name: "@id", value: id }],
73
+ }, {
74
+ enableCrossPartitionQuery: true,
75
+ maxItemCount: 1, // fetch small pages; still fan-out under the hood
76
+ });
77
+ const { resources: items /*, headers */ } = await iterator.fetchNext();
78
+ return {
79
+ engine: ENGINE,
80
+ data: items?.[0] ?? null
81
+ };
82
+ }
83
+ }
84
+ catch (error) {
85
+ return {
86
+ engine: ENGINE,
87
+ error: error instanceof Error ? error.message : 'Failed to retrieve document from Cosmos DB'
88
+ };
89
+ }
90
+ }
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/azure-cosmosdb/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAiCH,0BAgCC;AAOD,4BAgDC;AAtHD,4EAAqE;AAErE,0CAA6C;AAE7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAsBhC;;;;GAIG;AACI,KAAK,UAAU,OAAO,CA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IAAI,EAAE,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;YACzE,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAS;aAClB,CAAC;QACN,CAAC;aACI,CAAC;YACF,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC;gBACnC,KAAK,EAAE,kCAAkC;gBACzC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;aAC3C,EAAE;gBACC,yBAAyB,EAAE,IAAI;gBAC/B,YAAY,EAAE,CAAC,EAAE,kDAAkD;aACtE,CAAC,CAAC;YAEH,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,EAAE,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,CAAC;YACvE,OAAO;gBACH,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI;aAC3B,CAAC;QACN,CAAC;IAEL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,4CAA4C;SAC/F,CAAC;IACN,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview GCP Firestore implementation
3
+ */
4
+ import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
5
+ export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
6
+ export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gcp-firestore/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAI1H,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAG3F;AAGD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAGpG"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview GCP Firestore implementation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.connect = connect;
7
+ exports.retrieve = retrieve;
8
+ const ENGINE = "gcp-firestore";
9
+ async function connect(props) {
10
+ // TODO: Implement GCP Firestore connection
11
+ throw new Error('GCP Firestore connection not implemented');
12
+ }
13
+ async function retrieve(props) {
14
+ // TODO: Implement GCP Firestore retrieve by ID
15
+ throw new Error('GCP Firestore retrieve not implemented');
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gcp-firestore/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAMH,0BAGC;AAGD,4BAGC;AAXD,MAAM,MAAM,GAAG,eAAe,CAAC;AAExB,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,2CAA2C;IAC3C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAChE,CAAC;AAGM,KAAK,UAAU,QAAQ,CAAI,KAAqC;IACnE,+CAA+C;IAC/C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview Main export file for @encodeagent/platform-helper-data
3
+ */
4
+ export { connect, retrieve } from './wrapper';
5
+ export type { TDatabaseEngine, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps, IConnectionForServiceProps, IConnectDatabaseError, IRetrieveError } from './types';
6
+ export { ENGINE, URI, KEY, DATABASE_ID, DATABASE_CONTAINER_ID } from './types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG9C,YAAY,EACR,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,cAAc,EACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACH,MAAM,EACN,GAAG,EACH,GAAG,EACH,WAAW,EACX,qBAAqB,EACxB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Main export file for @encodeagent/platform-helper-data
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DATABASE_CONTAINER_ID = exports.DATABASE_ID = exports.KEY = exports.URI = exports.ENGINE = exports.retrieve = exports.connect = void 0;
7
+ // Export wrapper functions (main API)
8
+ var wrapper_1 = require("./wrapper");
9
+ Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return wrapper_1.connect; } });
10
+ Object.defineProperty(exports, "retrieve", { enumerable: true, get: function () { return wrapper_1.retrieve; } });
11
+ // Export all constants from types.ts
12
+ var types_1 = require("./types");
13
+ Object.defineProperty(exports, "ENGINE", { enumerable: true, get: function () { return types_1.ENGINE; } });
14
+ Object.defineProperty(exports, "URI", { enumerable: true, get: function () { return types_1.URI; } });
15
+ Object.defineProperty(exports, "KEY", { enumerable: true, get: function () { return types_1.KEY; } });
16
+ Object.defineProperty(exports, "DATABASE_ID", { enumerable: true, get: function () { return types_1.DATABASE_ID; } });
17
+ Object.defineProperty(exports, "DATABASE_CONTAINER_ID", { enumerable: true, get: function () { return types_1.DATABASE_CONTAINER_ID; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAsC;AACtC,qCAA8C;AAArC,kGAAA,OAAO,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAa1B,qCAAqC;AACrC,iCAMiB;AALb,+FAAA,MAAM,OAAA;AACN,4FAAA,GAAG,OAAA;AACH,4FAAA,GAAG,OAAA;AACH,oGAAA,WAAW,OAAA;AACX,8GAAA,qBAAqB,OAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview MongoDB implementation
3
+ */
4
+ import { IConnectionForServiceProps, IConnectionResult, IRetrieveResult, IRetrieveFromCloudServiceProps } from '../types';
5
+ export declare function connect(props: IConnectionForServiceProps): Promise<IConnectionResult>;
6
+ export declare function retrieve<T>(props: IRetrieveFromCloudServiceProps): Promise<IRetrieveResult<T>>;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mongo/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,eAAe,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAC;AAI1H,wBAAsB,OAAO,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAG3F;AAGD,wBAAsB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAGpG"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview MongoDB implementation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.connect = connect;
7
+ exports.retrieve = retrieve;
8
+ const ENGINE = "mongodb";
9
+ async function connect(props) {
10
+ // TODO: Implement MongoDB connection
11
+ throw new Error('MongoDB connection not implemented');
12
+ }
13
+ async function retrieve(props) {
14
+ // TODO: Implement MongoDB retrieve by ID
15
+ throw new Error('MongoDB retrieve not implemented');
16
+ }
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mongo/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAMH,0BAGC;AAGD,4BAGC;AAXD,MAAM,MAAM,GAAG,SAAS,CAAC;AAElB,KAAK,UAAU,OAAO,CAAC,KAAiC;IAC3D,qCAAqC;IACrC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAC1D,CAAC;AAGM,KAAK,UAAU,QAAQ,CAAI,KAAqC;IACnE,yCAAyC;IACzC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @fileoverview Type definitions for database helper utilities
3
+ */
4
+ export type TDatabaseEngine = 'azure-cosmosdb' | 'aws-dynamodb' | 'gcp-firestore' | 'mongodb';
5
+ export declare const ENGINE: TDatabaseEngine;
6
+ export declare const URI: string | undefined;
7
+ export declare const KEY: string | undefined;
8
+ export declare const DATABASE_ID: string;
9
+ export declare const DATABASE_CONTAINER_ID: string;
10
+ export interface IConnectionResult {
11
+ engine: TDatabaseEngine;
12
+ client?: any;
13
+ error?: string;
14
+ }
15
+ export interface IConnectionForServiceProps {
16
+ uri: string;
17
+ key: string;
18
+ }
19
+ export interface IRetrieveResult<T = any> {
20
+ engine: TDatabaseEngine;
21
+ data?: T;
22
+ error?: string;
23
+ }
24
+ export interface IConnectDatabaseError {
25
+ message: string;
26
+ code: string;
27
+ engine: string;
28
+ timestamp: string;
29
+ details?: any;
30
+ retryable?: boolean;
31
+ }
32
+ export interface IRetrieveError extends IConnectDatabaseError {
33
+ message: string;
34
+ code: string;
35
+ timestamp: string;
36
+ details?: any;
37
+ retryable?: boolean;
38
+ }
39
+ export interface IRetrieveFromCloudServiceProps {
40
+ client: any;
41
+ databaseId: string;
42
+ containerId?: string;
43
+ id: string;
44
+ partitionKey?: string;
45
+ }
46
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,cAAc,GAAG,eAAe,GAAG,SAAS,CAAC;AAE9F,eAAO,MAAM,MAAM,EAAwD,eAAe,CAAC;AAC3F,eAAO,MAAM,GAAG,oBAA2B,CAAC;AAC5C,eAAO,MAAM,GAAG,oBAA2B,CAAC;AAC5C,eAAO,MAAM,WAAW,QAAoC,CAAC;AAC7D,eAAO,MAAM,qBAAqB,QAA8C,CAAC;AAGjF,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,0BAA0B;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAGD,MAAM,WAAW,8BAA8B;IAC3C,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB"}
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Type definitions for database helper utilities
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DATABASE_CONTAINER_ID = exports.DATABASE_ID = exports.KEY = exports.URI = exports.ENGINE = void 0;
7
+ exports.ENGINE = (process.env.DATABASE_ENGINE || "azure-cosmosdb");
8
+ exports.URI = process.env.DATABASE_URI;
9
+ exports.KEY = process.env.DATABASE_KEY;
10
+ exports.DATABASE_ID = process.env.DATABASE_ID || 'core';
11
+ exports.DATABASE_CONTAINER_ID = process.env.DATABASE_CONTAINER_ID || "data";
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIU,QAAA,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gBAAgB,CAAoB,CAAC;AAC9E,QAAA,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC/B,QAAA,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC/B,QAAA,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC;AAChD,QAAA,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,MAAM,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Generic wrapper functions for multi-database operations
3
+ */
4
+ import { IConnectionResult, IRetrieveResult, TDatabaseEngine } from '../types';
5
+ export interface IConnectionProps {
6
+ engine?: TDatabaseEngine;
7
+ uri?: string;
8
+ key?: string;
9
+ }
10
+ /**
11
+ * Connect to database based on engine type
12
+ * @param props Database configuration with engine type
13
+ * @returns Promise<ConnectionResult>
14
+ */
15
+ export declare function connect(props: IConnectionProps): Promise<IConnectionResult>;
16
+ export interface IRetrieveProps {
17
+ engine?: TDatabaseEngine;
18
+ databaseId?: string;
19
+ containerId?: string;
20
+ partitionKey?: string;
21
+ id: string;
22
+ }
23
+ /**
24
+ * Retrieve document by ID from any database
25
+ * @param props IRetrieveProps
26
+ * @returns Promise<IRetrieveResult>
27
+ */
28
+ export declare const retrieve: (props: IRetrieveProps) => Promise<IRetrieveResult>;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAA8D,MAAM,UAAU,CAAC;AAW3I,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoEjF;AAGD,MAAM,WAAW,cAAc;IAC3B,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,OAAO,cAAc,KAAG,OAAO,CAAC,eAAe,CA4D7E,CAAA"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Generic wrapper functions for multi-database operations
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.retrieve = void 0;
7
+ exports.connect = connect;
8
+ const types_1 = require("../types");
9
+ const azure_cosmosdb_1 = require("../azure-cosmosdb");
10
+ const aws_dynamodb_1 = require("../aws-dynamodb");
11
+ const gcp_firestore_1 = require("../gcp-firestore");
12
+ const mongo_1 = require("../mongo");
13
+ const connections = {};
14
+ /**
15
+ * Connect to database based on engine type
16
+ * @param props Database configuration with engine type
17
+ * @returns Promise<ConnectionResult>
18
+ */
19
+ async function connect(props) {
20
+ const engine = props.engine ?? types_1.ENGINE;
21
+ if (!props.uri) {
22
+ return {
23
+ engine,
24
+ error: 'The database URI is required'
25
+ };
26
+ }
27
+ if (!props.key) {
28
+ return {
29
+ engine,
30
+ error: 'The database key is required'
31
+ };
32
+ }
33
+ const uri = props.uri ?? types_1.URI;
34
+ const key = props.key ?? types_1.KEY;
35
+ const connectionProps = {
36
+ uri,
37
+ key
38
+ };
39
+ let connection = connections[engine];
40
+ if (connection) {
41
+ return connection;
42
+ }
43
+ try {
44
+ switch (engine) {
45
+ case 'azure-cosmosdb':
46
+ {
47
+ connection = await (0, azure_cosmosdb_1.connect)(connectionProps);
48
+ break;
49
+ }
50
+ case 'aws-dynamodb':
51
+ {
52
+ connection = await (0, aws_dynamodb_1.connect)(connectionProps);
53
+ break;
54
+ }
55
+ case 'gcp-firestore':
56
+ {
57
+ connection = await (0, gcp_firestore_1.connect)(connectionProps);
58
+ break;
59
+ }
60
+ case 'mongodb':
61
+ {
62
+ connection = await (0, mongo_1.connect)(connectionProps);
63
+ break;
64
+ }
65
+ default:
66
+ connection =
67
+ {
68
+ engine,
69
+ error: 'Invalid engine type'
70
+ };
71
+ }
72
+ return connection;
73
+ }
74
+ catch (error) {
75
+ return {
76
+ engine,
77
+ error: error instanceof Error ? error.message : 'Unknown error occurred'
78
+ };
79
+ }
80
+ }
81
+ /**
82
+ * Retrieve document by ID from any database
83
+ * @param props IRetrieveProps
84
+ * @returns Promise<IRetrieveResult>
85
+ */
86
+ const retrieve = async (props) => {
87
+ const { id, partitionKey } = props;
88
+ const connection = await connect({ engine: props.engine });
89
+ const engine = connection.engine;
90
+ const databaseId = props.databaseId ?? types_1.DATABASE_ID;
91
+ const containerId = props.containerId ?? types_1.DATABASE_CONTAINER_ID;
92
+ if (!connection.client) {
93
+ return {
94
+ engine,
95
+ error: `The ${engine} client is required`
96
+ };
97
+ }
98
+ if (!containerId) {
99
+ return {
100
+ engine,
101
+ error: 'The containerId or process.env.CONTAINER_ID is required'
102
+ };
103
+ }
104
+ if (!id) {
105
+ return {
106
+ engine,
107
+ error: 'Record ID is required'
108
+ };
109
+ }
110
+ const retrieveProps = {
111
+ client: connection.client,
112
+ id,
113
+ databaseId,
114
+ containerId,
115
+ partitionKey
116
+ };
117
+ try {
118
+ switch (engine) {
119
+ case 'azure-cosmosdb':
120
+ return await (0, azure_cosmosdb_1.retrieve)(retrieveProps);
121
+ case 'aws-dynamodb':
122
+ return await (0, aws_dynamodb_1.retrieve)(retrieveProps);
123
+ case 'gcp-firestore':
124
+ return await (0, gcp_firestore_1.retrieve)(retrieveProps);
125
+ case 'mongodb':
126
+ return await (0, mongo_1.retrieve)(retrieveProps);
127
+ default:
128
+ return {
129
+ engine,
130
+ error: 'Invalid engine type'
131
+ };
132
+ }
133
+ }
134
+ catch (error) {
135
+ return {
136
+ engine,
137
+ error: error instanceof Error ? error.message : 'Unknown error occurred'
138
+ };
139
+ }
140
+ };
141
+ exports.retrieve = retrieve;
142
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wrapper/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAyBH,0BAoEC;AA1FD,oCA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AAM,EAAE,CAAC;YACb,KAAK,gBAAgB;gBACjB,OAAO,MAAM,IAAA,yBAAiB,EAAC,aAAa,CAAC,CAAC;YAClD,KAAK,cAAc;gBACf,OAAO,MAAM,IAAA,uBAAe,EAAC,aAAa,CAAC,CAAC;YAChD,KAAK,eAAe;gBAChB,OAAO,MAAM,IAAA,wBAAe,EAAC,aAAa,CAAC,CAAC;YAChD,KAAK,SAAS;gBACV,OAAO,MAAM,IAAA,gBAAiB,EAAC,aAAa,CAAC,CAAC;YAClD;gBACI,OAAO;oBACH,MAAM;oBACN,KAAK,EAAE,qBAAqB;iBAC/B,CAAC;QACV,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,MAAM;YACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;SAC3E,CAAC;IACN,CAAC;AACL,CAAC,CAAA;AA5DY,QAAA,QAAQ,YA4DpB"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@encodeagent/platform-helper-data",
3
+ "version": "1.2510.1041539",
4
+ "engines": {
5
+ "node": ">20.0.0 <23.0.0"
6
+ },
7
+ "description": "Comprehensive TypeScript data library for the EncodeAgent platform with database utilities, query builders, migrations, and more",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist/**/*",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "build:watch": "tsc --watch",
17
+ "clean": "rm -rf dist",
18
+ "prepublishOnly": "npm run clean && npm run build",
19
+ "test": "jest",
20
+ "test:watch": "jest --watch",
21
+ "lint": "eslint src/**/*.ts",
22
+ "lint:fix": "eslint src/**/*.ts --fix"
23
+ },
24
+ "keywords": [
25
+ "database",
26
+ "data",
27
+ "typescript",
28
+ "encodeagent",
29
+ "helper"
30
+ ],
31
+ "author": "EncodeAgent Team <team@encodeagent.com>",
32
+ "license": "SEE LICENSE IN LICENSE",
33
+ "dependencies": {
34
+ "@aws-sdk/client-dynamodb": "^3.879.0",
35
+ "@aws-sdk/util-dynamodb": "^3.879.0",
36
+ "@azure/cosmos": "^4.5.0",
37
+ "@encodeagent/platform-helper-util": "^1.2510.1041527",
38
+ "lodash": "^4.17.21",
39
+ "uuid": "^9.0.1"
40
+ },
41
+ "devDependencies": {
42
+ "@types/jest": "^29.5.5",
43
+ "@types/lodash": "^4.14.199",
44
+ "@types/node": "^20.6.0",
45
+ "@types/uuid": "^9.0.4",
46
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
47
+ "@typescript-eslint/parser": "^6.7.0",
48
+ "dotenv": "^17.2.1",
49
+ "eslint": "^8.49.0",
50
+ "jest": "^29.7.0",
51
+ "ts-jest": "^29.1.1",
52
+ "typescript": "^5.2.2"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/EncodeAgent/encodeagent-platform-helper-data.git",
57
+ "directory": "helper/data"
58
+ },
59
+ "publishConfig": {
60
+ "access": "restricted"
61
+ }
62
+ }