@sphereon/ssi-sdk.agent-config 0.33.1-feature.vcdm2.4 → 0.33.1-feature.vcdm2.tsup.19

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/package.json CHANGED
@@ -1,29 +1,41 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.agent-config",
3
- "version": "0.33.1-feature.vcdm2.4+9f634bdb",
3
+ "version": "0.33.1-feature.vcdm2.tsup.19+db508b44",
4
4
  "source": "src/index.ts",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
7
19
  "scripts": {
8
- "build": "tsc --build",
9
- "build:clean": "tsc --build --clean && tsc --build"
20
+ "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
10
21
  },
11
22
  "dependencies": {
12
23
  "@veramo/core": "4.2.0",
13
24
  "debug": "^4.3.5",
14
25
  "jsonpointer": "^5.0.1",
15
- "typeorm": "^0.3.21",
26
+ "reflect-metadata": "^0.2.2",
27
+ "typeorm": "^0.3.22",
16
28
  "url-parse": "^1.5.10",
17
29
  "yaml": "^2.4.5"
18
30
  },
19
31
  "devDependencies": {
20
32
  "@types/debug": "^4.1.12",
21
33
  "@types/url-parse": "^1.4.11",
22
- "typescript": "5.4.2"
34
+ "typescript": "5.8.3"
23
35
  },
24
36
  "files": [
25
- "dist/**/*",
26
- "src/**/*",
37
+ "dist",
38
+ "src",
27
39
  "README.md",
28
40
  "LICENSE"
29
41
  ],
@@ -38,6 +50,5 @@
38
50
  "SSI",
39
51
  "Agent"
40
52
  ],
41
- "nx": {},
42
- "gitHead": "9f634bdb714061141e277508c124b08d626f6036"
53
+ "gitHead": "db508b447fb1f769700f1d5e7cd8196653f4f794"
43
54
  }
@@ -1,8 +1,7 @@
1
1
  import Debug from 'debug'
2
- import { DataSource } from 'typeorm'
3
- import { BaseDataSourceOptions } from 'typeorm/data-source/BaseDataSourceOptions'
4
-
5
- import { DataSourceOptions } from 'typeorm/data-source/DataSourceOptions'
2
+ import { DataSource } from 'typeorm/data-source/DataSource.js'
3
+ import { BaseDataSourceOptions } from 'typeorm/data-source/BaseDataSourceOptions.js'
4
+ import { DataSourceOptions } from 'typeorm/data-source/DataSourceOptions.js'
6
5
 
7
6
  const debug = Debug(`sphereon:ssi-sdk:database`)
8
7
 
@@ -1,21 +0,0 @@
1
- import { IAgentContext, ICredentialVerifier, IDataStore, IDataStoreORM, IDIDManager, IKeyManager, IPluginMethodMap, IResolver, ICredentialIssuer, ICredentialStatusVerifier } from '@veramo/core';
2
- /**
3
- * Allows to get a type agent context plugin methods based on provided or inferred types and at least one method for these plugin(s)
4
- * @param context Tje agent context to check against
5
- * @param requiredMethod One or more method the plugin provides, so we can check availability and thus plugin presence
6
- */
7
- export declare function contextHasPlugin<Plugins extends IPluginMethodMap>(context: IAgentContext<any>, requiredMethod: string | string[]): context is IAgentContext<Plugins>;
8
- /**
9
- * The below methods are convenience methods to directly get the appropriate context after calling the respective method
10
- *
11
- * @param context
12
- */
13
- export declare function contextHasKeyManager(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IKeyManager>;
14
- export declare function contextHasDidManager(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IResolver & IDIDManager>;
15
- export declare function contextHasDidResolver(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IResolver>;
16
- export declare function contextHasCredentialIssuer(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialIssuer>;
17
- export declare function contextHasCredentialVerifier(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialVerifier>;
18
- export declare function contextHasCredentialStatusVerifier(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<ICredentialStatusVerifier>;
19
- export declare function contextHasDataStore(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IDataStore>;
20
- export declare function contextHasDataStoreORM(context: IAgentContext<IPluginMethodMap>): context is IAgentContext<IDataStoreORM>;
21
- //# sourceMappingURL=agentContextUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentContextUtils.d.ts","sourceRoot":"","sources":["../src/agentContextUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,cAAc,CAAA;AAErB;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,gBAAgB,EAC/D,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,EAC3B,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,GAChC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAInC;AAED;;;;GAIG;AAEH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAEpH;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,SAAS,GAAG,WAAW,CAAC,CAEhI;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,CAEnH;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAEhI;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,mBAAmB,CAAC,CAEpI;AAED,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,yBAAyB,CAAC,CAEhJ;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,UAAU,CAAC,CAElH;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,aAAa,CAAC,CAExH"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Allows to get a type agent context plugin methods based on provided or inferred types and at least one method for these plugin(s)
3
- * @param context Tje agent context to check against
4
- * @param requiredMethod One or more method the plugin provides, so we can check availability and thus plugin presence
5
- */
6
- export function contextHasPlugin(context, requiredMethod) {
7
- const methods = Array.isArray(requiredMethod) ? requiredMethod : [requiredMethod];
8
- const allMethods = context.agent.availableMethods();
9
- return methods.every((method) => allMethods.includes(method));
10
- }
11
- /**
12
- * The below methods are convenience methods to directly get the appropriate context after calling the respective method
13
- *
14
- * @param context
15
- */
16
- export function contextHasKeyManager(context) {
17
- return contextHasPlugin(context, 'keyManagerGet');
18
- }
19
- export function contextHasDidManager(context) {
20
- return contextHasPlugin(context, 'didManagerGet'); // IResolver is always required for IDIDManager
21
- }
22
- export function contextHasDidResolver(context) {
23
- return contextHasPlugin(context, 'resolveDid'); // IResolver is always required for IDIDManager
24
- }
25
- export function contextHasCredentialIssuer(context) {
26
- return contextHasPlugin(context, ['createVerifiableCredential', 'createVerifiablePresentation']); // W3C Credential issuer
27
- }
28
- export function contextHasCredentialVerifier(context) {
29
- return contextHasPlugin(context, ['verifyCredential', 'verifyPresentation']); // W3c Credential Verifier
30
- }
31
- export function contextHasCredentialStatusVerifier(context) {
32
- return contextHasPlugin(context, ['checkCredentialStatus']); // W3c Credential status Verifier
33
- }
34
- export function contextHasDataStore(context) {
35
- return contextHasPlugin(context, ['dataStoreGetVerifiableCredential', 'dataStoreGetVerifiablePresentation']);
36
- }
37
- export function contextHasDataStoreORM(context) {
38
- return contextHasPlugin(context, ['dataStoreORMGetVerifiableCredentials', 'dataStoreORMGetVerifiablePresentations']);
39
- }
40
- //# sourceMappingURL=agentContextUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentContextUtils.js","sourceRoot":"","sources":["../src/agentContextUtils.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA2B,EAC3B,cAAiC;IAEjC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAA;IACjF,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAA;IACnD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED;;;;GAIG;AAEH,MAAM,UAAU,oBAAoB,CAAC,OAAwC;IAC3E,OAAO,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAwC;IAC3E,OAAO,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA,CAAC,+CAA+C;AACnG,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAwC;IAC5E,OAAO,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA,CAAC,+CAA+C;AAChG,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAwC;IACjF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,4BAA4B,EAAE,8BAA8B,CAAC,CAAC,CAAA,CAAC,wBAAwB;AAC3H,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAwC;IACnF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC,CAAA,CAAC,0BAA0B;AACzG,CAAC;AAED,MAAM,UAAU,kCAAkC,CAAC,OAAwC;IACzF,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,uBAAuB,CAAC,CAAC,CAAA,CAAC,iCAAiC;AAC/F,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAwC;IAC1E,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,kCAAkC,EAAE,oCAAoC,CAAC,CAAC,CAAA;AAC9G,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAwC;IAC7E,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC,sCAAsC,EAAE,wCAAwC,CAAC,CAAC,CAAA;AACtH,CAAC"}
@@ -1,54 +0,0 @@
1
- import { TAgent, IPluginMethodMap, IAgentOptions } from '@veramo/core';
2
- /**
3
- * Creates a Veramo agent from a config object containing an `/agent` pointer.
4
- * @param config - The configuration object
5
- *
6
- * @see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for details on
7
- * the configuration options.
8
- *
9
- * @beta - This API may change without a major version bump
10
- */
11
- export declare function createAgentFromConfig<T extends IPluginMethodMap>(config: object): Promise<TAgent<T>>;
12
- /**
13
- * Helper function to create a new instance of the {@link Agent} class with correct type
14
- *
15
- * @remarks
16
- * Use {@link TAgent} to configure agent type (list of available methods) for autocomplete in IDE
17
- *
18
- * @example
19
- * ```typescript
20
- * import { createAgent, IResolver, IMessageHandler } from '@veramo/core'
21
- * import { AgentRestClient } from '@veramo/remote-client'
22
- * import { CredentialIssuer, ICredentialIssuer } from '@veramo/credential-w3c'
23
- * const agent = createAgent<IResolver & IMessageHandler & ICredentialIssuer>({
24
- * plugins: [
25
- * new CredentialIssuer(),
26
- * new AgentRestClient({
27
- * url: 'http://localhost:3002/agent',
28
- * enabledMethods: [
29
- * 'resolveDid',
30
- * 'handleMessage',
31
- * ],
32
- * }),
33
- * ],
34
- * })
35
- * ```
36
- * @param options - Agent configuration options
37
- * @returns configured agent
38
- * @public
39
- */
40
- export declare function createAgent<T extends IPluginMethodMap, C = Record<string, any>>(options: IAgentOptions & {
41
- context?: C;
42
- }): Promise<TAgent<T> & {
43
- context?: C;
44
- }>;
45
- /**
46
- * Parses a yaml config file and returns a config object
47
- * @param filePath
48
- */
49
- export declare const getConfig: (filePath: string | Buffer | URL) => Promise<{
50
- version?: number;
51
- [x: string]: any;
52
- }>;
53
- export declare function getAgent<T extends IPluginMethodMap>(fileName: string): Promise<TAgent<T>>;
54
- //# sourceMappingURL=agentCreator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentCreator.d.ts","sourceRoot":"","sources":["../src/agentCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAItE;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,SAAS,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAI1G;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,gBAAgB,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnF,OAAO,EAAE,aAAa,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,GACvC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,CAGtC;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,aAAoB,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CA2B/G,CAAA;AAED,wBAAsB,QAAQ,CAAC,CAAC,SAAS,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAO/F"}
@@ -1,88 +0,0 @@
1
- import { createObjects } from './objectCreator';
2
- import yaml from 'yaml';
3
- /**
4
- * Creates a Veramo agent from a config object containing an `/agent` pointer.
5
- * @param config - The configuration object
6
- *
7
- * @see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for details on
8
- * the configuration options.
9
- *
10
- * @beta - This API may change without a major version bump
11
- */
12
- export async function createAgentFromConfig(config) {
13
- // @ts-ignore
14
- const { agent } = await createObjects(config, { agent: '/agent' });
15
- return agent;
16
- }
17
- /**
18
- * Helper function to create a new instance of the {@link Agent} class with correct type
19
- *
20
- * @remarks
21
- * Use {@link TAgent} to configure agent type (list of available methods) for autocomplete in IDE
22
- *
23
- * @example
24
- * ```typescript
25
- * import { createAgent, IResolver, IMessageHandler } from '@veramo/core'
26
- * import { AgentRestClient } from '@veramo/remote-client'
27
- * import { CredentialIssuer, ICredentialIssuer } from '@veramo/credential-w3c'
28
- * const agent = createAgent<IResolver & IMessageHandler & ICredentialIssuer>({
29
- * plugins: [
30
- * new CredentialIssuer(),
31
- * new AgentRestClient({
32
- * url: 'http://localhost:3002/agent',
33
- * enabledMethods: [
34
- * 'resolveDid',
35
- * 'handleMessage',
36
- * ],
37
- * }),
38
- * ],
39
- * })
40
- * ```
41
- * @param options - Agent configuration options
42
- * @returns configured agent
43
- * @public
44
- */
45
- export async function createAgent(options) {
46
- //@ts-ignore
47
- return new Agent(options);
48
- }
49
- /**
50
- * Parses a yaml config file and returns a config object
51
- * @param filePath
52
- */
53
- export const getConfig = async (filePath) => {
54
- let fileContent;
55
- // read file async
56
- try {
57
- const fs = await import(/* webpackIgnore: true */ 'fs');
58
- fileContent = await fs.promises.readFile(filePath, 'utf8');
59
- }
60
- catch (e) {
61
- console.log('Config file not found: ' + filePath);
62
- console.log('Use "veramo config create" to create one');
63
- process.exit(1);
64
- }
65
- let config;
66
- try {
67
- config = yaml.parse(fileContent, { prettyErrors: true });
68
- }
69
- catch (e) {
70
- console.error(`Unable to parse config file: ${e.message} ${e.linePos}`);
71
- process.exit(1);
72
- }
73
- if (config?.version != 3) {
74
- console.error('Unsupported configuration file version:', config.version);
75
- process.exit(1);
76
- }
77
- return config;
78
- };
79
- export async function getAgent(fileName) {
80
- try {
81
- return await createAgentFromConfig(await getConfig(fileName));
82
- }
83
- catch (e) {
84
- console.log('Unable to create agent from ' + fileName + '.', e.message);
85
- process.exit(1);
86
- }
87
- }
88
- //# sourceMappingURL=agentCreator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agentCreator.js","sourceRoot":"","sources":["../src/agentCreator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAA6B,MAAc;IACpF,aAAa;IACb,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IAClE,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAwC;IAExC,YAAY;IACZ,OAAO,IAAI,KAAK,CAAC,OAAO,CAAc,CAAA;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,QAA+B,EAAmD,EAAE;IAClH,IAAI,WAAmB,CAAA;IAEvB,kBAAkB;IAClB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB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A;IACjB,CAAC;AACH,CAAC"}
@@ -1,45 +0,0 @@
1
- import { DataSource } from 'typeorm';
2
- import { BaseDataSourceOptions } from 'typeorm/data-source/BaseDataSourceOptions';
3
- import { DataSourceOptions } from 'typeorm/data-source/DataSourceOptions';
4
- export declare class DataSources {
5
- get defaultDbType(): SupportedDatabaseType;
6
- set defaultDbType(value: SupportedDatabaseType);
7
- private dataSources;
8
- private configs;
9
- private _defaultDbType;
10
- private static singleton;
11
- static singleInstance(): DataSources;
12
- static newInstance(configs?: Map<string, DataSourceOptions>): DataSources;
13
- private constructor();
14
- addConfig(dbName: string, config: DataSourceOptions): this;
15
- deleteConfig(dbName: string): this;
16
- has(dbName: string): boolean;
17
- delete(dbName: string): this;
18
- getConfig(dbName: string): BaseDataSourceOptions;
19
- getDbNames(): string[];
20
- getDbConnection(dbName: string): Promise<DataSource>;
21
- }
22
- export type SupportedDatabaseType = 'postgres' | 'sqlite' | 'react-native';
23
- export type DateTimeType = 'timestamp' | 'datetime';
24
- export type DateType = 'date';
25
- /**
26
- * Gets the database connection.
27
- *
28
- * Also makes sure that migrations are run (versioning for DB schema's), so we can properly update over time
29
- *
30
- * @param connectionName The database name
31
- * @param opts
32
- */
33
- export declare const getDbConnection: (connectionName: string, opts?: {
34
- config: BaseDataSourceOptions | any;
35
- }) => Promise<DataSource>;
36
- export declare const dropDatabase: (dbName: string, opts?: {
37
- removeDataSource?: boolean;
38
- }) => Promise<void>;
39
- /**
40
- * Runs a migration down (drops DB schema)
41
- * @param dataSource
42
- */
43
- export declare const revertMigration: (dataSource: DataSource) => Promise<void>;
44
- export declare const resetDatabase: (dbName: string) => Promise<void>;
45
- //# sourceMappingURL=dataSources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataSources.d.ts","sourceRoot":"","sources":["../src/dataSources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2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,eAAO,MAAM,eAAe,eAAsB,UAAU,KAAG,OAAO,CAAC,IAAI,CAM1E,CAAA;AACD,eAAO,MAAM,aAAa,WAAkB,MAAM,KAAG,OAAO,CAAC,IAAI,CAIhE,CAAA"}
@@ -1,131 +0,0 @@
1
- import Debug from 'debug';
2
- import { DataSource } from 'typeorm';
3
- const debug = Debug(`sphereon:ssi-sdk:database`);
4
- export class DataSources {
5
- get defaultDbType() {
6
- return this._defaultDbType;
7
- }
8
- set defaultDbType(value) {
9
- this._defaultDbType = value;
10
- }
11
- dataSources = new Map();
12
- configs = new Map();
13
- _defaultDbType = 'sqlite';
14
- static singleton;
15
- static singleInstance() {
16
- if (!DataSources.singleton) {
17
- DataSources.singleton = new DataSources();
18
- }
19
- return DataSources.singleton;
20
- }
21
- static newInstance(configs) {
22
- return new DataSources(configs);
23
- }
24
- constructor(configs) {
25
- ;
26
- (configs ?? new Map()).forEach((config, name) => this.addConfig(name, config));
27
- }
28
- addConfig(dbName, config) {
29
- this.configs.set(dbName, config);
30
- // yes we are aware last one wins
31
- this._defaultDbType = config.type;
32
- return this;
33
- }
34
- deleteConfig(dbName) {
35
- this.configs.delete(dbName);
36
- return this;
37
- }
38
- has(dbName) {
39
- return this.configs.has(dbName) && this.dataSources.has(dbName);
40
- }
41
- delete(dbName) {
42
- this.deleteConfig(dbName);
43
- this.dataSources.delete(dbName);
44
- return this;
45
- }
46
- getConfig(dbName) {
47
- const config = this.configs.get(dbName);
48
- if (!config) {
49
- throw Error(`No DB config found for ${dbName}`);
50
- }
51
- return config;
52
- }
53
- getDbNames() {
54
- return [...this.configs.keys()];
55
- }
56
- async getDbConnection(dbName) {
57
- const config = this.getConfig(dbName);
58
- if (!this._defaultDbType) {
59
- this._defaultDbType = config.type;
60
- }
61
- /*if (config.synchronize) {
62
- return Promise.reject(
63
- `WARNING: Automatic migrations need to be disabled in this app! Adjust the database configuration and set synchronize to false`
64
- )
65
- }*/
66
- let dataSource = this.dataSources.get(dbName);
67
- if (dataSource) {
68
- return dataSource;
69
- }
70
- dataSource = await new DataSource({ ...config, name: dbName }).initialize();
71
- this.dataSources.set(dbName, dataSource);
72
- if (config.synchronize) {
73
- debug(`WARNING: Automatic migrations need to be disabled in this app! Adjust the database configuration and set synchronize to false`);
74
- }
75
- else if (config.migrationsRun) {
76
- debug(`Migrations are currently managed from config. Please set migrationsRun and synchronize to false to get consistent behaviour. We run migrations from code explicitly`);
77
- }
78
- else {
79
- debug(`Running ${dataSource.migrations.length} migration(s) from code if needed...`);
80
- await dataSource.runMigrations();
81
- debug(`${dataSource.migrations.length} migration(s) from code were inspected and applied`);
82
- }
83
- return dataSource;
84
- }
85
- }
86
- /**
87
- * Gets the database connection.
88
- *
89
- * Also makes sure that migrations are run (versioning for DB schema's), so we can properly update over time
90
- *
91
- * @param connectionName The database name
92
- * @param opts
93
- */
94
- export const getDbConnection = async (connectionName, opts) => {
95
- if (!DataSources.singleInstance().has(connectionName) && opts?.config) {
96
- DataSources.singleInstance().addConfig(connectionName, opts?.config);
97
- }
98
- return DataSources.singleInstance().getDbConnection(connectionName);
99
- };
100
- export const dropDatabase = async (dbName, opts) => {
101
- const { removeDataSource = false } = { ...opts };
102
- if (!DataSources.singleInstance().has(dbName)) {
103
- return Promise.reject(Error(`No database present with name: ${dbName}`));
104
- }
105
- const connection = await getDbConnection(dbName);
106
- await connection.dropDatabase();
107
- if (removeDataSource) {
108
- DataSources.singleInstance().delete(dbName);
109
- }
110
- else if (!connection.isInitialized) {
111
- await connection.initialize();
112
- }
113
- };
114
- /**
115
- * Runs a migration down (drops DB schema)
116
- * @param dataSource
117
- */
118
- export const revertMigration = async (dataSource) => {
119
- if (dataSource.isInitialized) {
120
- await dataSource.undoLastMigration();
121
- }
122
- else {
123
- console.error('DataSource is not initialized');
124
- }
125
- };
126
- export const resetDatabase = async (dbName) => {
127
- await dropDatabase(dbName);
128
- const connection = await getDbConnection(dbName);
129
- await connection.runMigrations();
130
- };
131
- //# sourceMappingURL=dataSources.js.map
@@ -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AC9C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,MAAM,UAAU,GAAe,MAAM,eAAe,CAAC,MAAM,CAAC,CAAA;IAC5D,MAAM,UAAU,CAAC,YAAY,EAAE,CAAA;IAC/B,IAAI,gBAAgB,EAAE,CAAC;QACrB,WAAW,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC7C,CAAC;SAAM,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QACrC,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;IAC/B,CAAC;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,UAAsB,EAAiB,EAAE;IAC7E,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;QAC7B,MAAM,UAAU,CAAC,iBAAiB,EAAE,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAChD,CAAC;AACH,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAiB,EAAE;IACnE,MAAM,YAAY,CAAC,MAAM,CAAC,CAAA;IAC1B,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,UAAU,CAAC,aAAa,EAAE,CAAA;AAClC,CAAC,CAAA"}
package/dist/generic.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Accept a Type or a Promise of that Type.
3
- *
4
- * @internal
5
- */
6
- export type OrPromise<T> = T | Promise<T>;
7
- //# sourceMappingURL=generic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA"}
package/dist/generic.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=generic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Creates objects from a configuration object and a set of pointers.
3
- *
4
- * Example:
5
- * ```ts
6
- * const { url } = createObjects({ "rpcUrl": "http://localhost:8545", }, { url: '/rpcUrl' })
7
- * ```
8
- *
9
- * The config can contain references (`$ref`) to other objects within using JSON pointers.
10
- * Example:
11
- * ```json
12
- * {
13
- * "rpcUrl": "http://localhost:8545",
14
- * "endpoint": {
15
- * "url": {
16
- * "$ref": "/rpcUrl"
17
- * }
18
- * }
19
- * }
20
- * ```
21
- *
22
- * The config object can also contain references to NPM modules using the `$require` property.
23
- * Example:
24
- * ```json
25
- * {
26
- * "agent": {
27
- * "$require": "@veramo/core#Agent",
28
- * "$args": {
29
- * "plugins": [
30
- * { "$require": "@veramo/did-comm#DIDComm" },
31
- * ]
32
- * }
33
- * }
34
- * }
35
- * ```
36
- *
37
- * Environment variables can also be specified using the `$env` property.
38
- *
39
- * @see Please see {@link https://veramo.io/docs/veramo_agent/configuration_internals | Configuration Internals} for
40
- * more information.
41
- *
42
- * @param config - The configuration object
43
- * @param pointers - A map of JSON pointers to objects within that config that you wish to create
44
- *
45
- * @beta - This API may change without a major version bump
46
- */
47
- export declare function createObjects(config: object, pointers: Record<string, string>): Promise<Record<string, any>>;
48
- //# sourceMappingURL=objectCreator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectCreator.d.ts","sourceRoot":"","sources":["../src/objectCreator.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAsGlH"}