@nevermined-io/commons 0.0.1

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.
Files changed (56) hide show
  1. package/README.md +7 -0
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +4 -0
  5. package/dist/lib/constants/AssetConstants.d.ts +4 -0
  6. package/dist/lib/constants/AssetConstants.d.ts.map +1 -0
  7. package/dist/lib/constants/AssetConstants.js +3 -0
  8. package/dist/lib/constants/index.d.ts +3 -0
  9. package/dist/lib/constants/index.d.ts.map +1 -0
  10. package/dist/lib/constants/index.js +1 -0
  11. package/dist/lib/ddo/DDO.d.ts +40 -0
  12. package/dist/lib/ddo/DDO.d.ts.map +1 -0
  13. package/dist/lib/ddo/DDO.js +97 -0
  14. package/dist/lib/ddo/index.d.ts +2 -0
  15. package/dist/lib/ddo/index.d.ts.map +1 -0
  16. package/dist/lib/ddo/index.js +1 -0
  17. package/dist/lib/types/ApiResponseTypes.d.ts +46 -0
  18. package/dist/lib/types/ApiResponseTypes.d.ts.map +1 -0
  19. package/dist/lib/types/ApiResponseTypes.js +39 -0
  20. package/dist/lib/types/ContractsTypes.d.ts +90 -0
  21. package/dist/lib/types/ContractsTypes.d.ts.map +1 -0
  22. package/dist/lib/types/ContractsTypes.js +26 -0
  23. package/dist/lib/types/DDOTypes.d.ts +134 -0
  24. package/dist/lib/types/DDOTypes.d.ts.map +1 -0
  25. package/dist/lib/types/DDOTypes.js +14 -0
  26. package/dist/lib/types/GeneralTypes.d.ts +28 -0
  27. package/dist/lib/types/GeneralTypes.d.ts.map +1 -0
  28. package/dist/lib/types/GeneralTypes.js +1 -0
  29. package/dist/lib/types/MetadataTypes.d.ts +130 -0
  30. package/dist/lib/types/MetadataTypes.d.ts.map +1 -0
  31. package/dist/lib/types/MetadataTypes.js +62 -0
  32. package/dist/lib/types/OrganizationResponseTypes.d.ts +150 -0
  33. package/dist/lib/types/OrganizationResponseTypes.d.ts.map +1 -0
  34. package/dist/lib/types/OrganizationResponseTypes.js +124 -0
  35. package/dist/lib/types/TranscoderTypes.d.ts +28 -0
  36. package/dist/lib/types/TranscoderTypes.d.ts.map +1 -0
  37. package/dist/lib/types/TranscoderTypes.js +30 -0
  38. package/dist/lib/types/index.d.ts +7 -0
  39. package/dist/lib/types/index.d.ts.map +1 -0
  40. package/dist/lib/types/index.js +6 -0
  41. package/dist/lib/types/types.d.ts +228 -0
  42. package/dist/lib/types/types.d.ts.map +1 -0
  43. package/dist/lib/types/types.js +152 -0
  44. package/package.json +22 -0
  45. package/src/index.ts +4 -0
  46. package/src/lib/constants/AssetConstants.ts +7 -0
  47. package/src/lib/constants/index.ts +2 -0
  48. package/src/lib/ddo/DDO.ts +121 -0
  49. package/src/lib/ddo/index.ts +1 -0
  50. package/src/lib/types/ContractsTypes.ts +113 -0
  51. package/src/lib/types/DDOTypes.ts +149 -0
  52. package/src/lib/types/GeneralTypes.ts +31 -0
  53. package/src/lib/types/MetadataTypes.ts +145 -0
  54. package/src/lib/types/TranscoderTypes.ts +29 -0
  55. package/src/lib/types/index.ts +6 -0
  56. package/src/lib/types/types.ts +264 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # commons
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build commons` to build the library.
@@ -0,0 +1,5 @@
1
+ export * from './lib/types/index.js';
2
+ export * from './lib/ddo/index.js';
3
+ export * from './lib/constants/index.js';
4
+ export { DDO } from './lib/ddo/DDO.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './lib/types/index.js';
2
+ export * from './lib/ddo/index.js';
3
+ export * from './lib/constants/index.js';
4
+ export { DDO } from './lib/ddo/DDO.js';
@@ -0,0 +1,4 @@
1
+ export declare const NETWORK_FEE_DENOMINATOR = 10000n;
2
+ export type EncryptionMethod = 'PSK-RSA' | 'PSK-ECDSA';
3
+ export declare const DEFAULT_ENCRYPTION_METHOD: EncryptionMethod;
4
+ //# sourceMappingURL=AssetConstants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetConstants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants/AssetConstants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,SAAS,CAAA;AAG7C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,CAAA;AAGtD,eAAO,MAAM,yBAAyB,EAAgB,gBAAgB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export const NETWORK_FEE_DENOMINATOR = 10000n;
2
+ // The default encryption method
3
+ export const DEFAULT_ENCRYPTION_METHOD = 'PSK-RSA';
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_ENCRYPTION_METHOD, NETWORK_FEE_DENOMINATOR } from './AssetConstants.js';
2
+ export type { EncryptionMethod } from './AssetConstants.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AACxF,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1 @@
1
+ export { DEFAULT_ENCRYPTION_METHOD, NETWORK_FEE_DENOMINATOR } from './AssetConstants.js';
@@ -0,0 +1,40 @@
1
+ import { DIDAgent, Plan } from '../types/ContractsTypes.js';
2
+ import { Metadata, NvmConfig } from '../types/DDOTypes.js';
3
+ type Registry = DIDAgent | Plan;
4
+ export declare class DDO {
5
+ /**
6
+ * Serializes the DDO object.
7
+ * @param ddo - The {@link DDO} to be serialized.
8
+ * @returns DDO serialized.
9
+ */
10
+ static serialize(ddo: DDO): string;
11
+ /**
12
+ * Deserializes the DDO object.
13
+ * @param ddoString - The serialized {@link DDO} to be deserialized.
14
+ * @returns The deserialized {@link DDO}.
15
+ */
16
+ static deserialize(ddoString: string): DDO;
17
+ /**
18
+ * DID, decentralizes ID.
19
+ */
20
+ id: string;
21
+ ['@context']: string;
22
+ _nvm: NvmConfig;
23
+ created: string;
24
+ updated?: string;
25
+ metadata: Metadata;
26
+ registry: Registry;
27
+ constructor(ddo?: Partial<DDO>);
28
+ }
29
+ export declare class AgentDDO extends DDO {
30
+ registry: DIDAgent;
31
+ constructor(ddo?: Partial<AgentDDO>);
32
+ static getInstance(userId: string, userAddress: string, appId?: string): AgentDDO;
33
+ }
34
+ export declare class PlanDDO extends DDO {
35
+ registry: Plan;
36
+ constructor(ddo?: Partial<PlanDDO>);
37
+ static getInstance(userId: string, userAddress: string, appId?: string): PlanDDO;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=DDO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DDO.d.ts","sourceRoot":"","sources":["../../../src/lib/ddo/DDO.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,IAAI,EAAe,MAAM,4BAA4B,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAQ1D,KAAK,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAA;AAE/B,qBAAa,GAAG;IACd;;;;OAIG;WACW,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IAIzC;;;;OAIG;WACW,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG;IAMjD;;OAEG;IACI,EAAE,SAAK;IAIP,CAAC,UAAU,CAAC,SAA4B;IAExC,IAAI,EAAE,SAAS,CAA2D;IAE1E,OAAO,EAAE,MAAM,CAAqD;IAEpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,QAAQ,EAAE,QAAQ,CAgBxB;IAEM,QAAQ,EAAE,QAAQ,CAAA;gBAEN,GAAG,GAAE,OAAO,CAAC,GAAG,CAAM;CAK1C;AAED,qBAAa,QAAS,SAAQ,GAAG;IACf,QAAQ,EAAE,QAAQ,CAMjC;gBAEkB,GAAG,GAAE,OAAO,CAAC,QAAQ,CAAM;WAIhC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ;CAOzF;AAED,qBAAa,OAAQ,SAAQ,GAAG;IACd,QAAQ,EAAE,IAAI,CAK7B;gBAEkB,GAAG,GAAE,OAAO,CAAC,OAAO,CAAM;WAI/B,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;CAYxF"}
@@ -0,0 +1,97 @@
1
+ const jsonReplacer = (_key, value) => {
2
+ // Modify the value or return undefined to exclude the property
3
+ return typeof value === 'bigint' ? value.toString() : value;
4
+ };
5
+ export class DDO {
6
+ /**
7
+ * Serializes the DDO object.
8
+ * @param ddo - The {@link DDO} to be serialized.
9
+ * @returns DDO serialized.
10
+ */
11
+ static serialize(ddo) {
12
+ return JSON.stringify(ddo, jsonReplacer, 2);
13
+ }
14
+ /**
15
+ * Deserializes the DDO object.
16
+ * @param ddoString - The serialized {@link DDO} to be deserialized.
17
+ * @returns The deserialized {@link DDO}.
18
+ */
19
+ static deserialize(ddoString) {
20
+ const ddo = JSON.parse(ddoString);
21
+ return new DDO(ddo);
22
+ }
23
+ /**
24
+ * DID, decentralizes ID.
25
+ */
26
+ id = '';
27
+ // public didSeed = ''
28
+ ['@context'] = 'https://w3id.org/did/v1';
29
+ _nvm = { userId: '', userAddress: '', appId: '', versions: [] };
30
+ created = new Date().toISOString().replace(/\.[0-9]{3}/, '');
31
+ updated;
32
+ metadata = {
33
+ serviceEndpoint: '',
34
+ main: {
35
+ name: '',
36
+ description: '',
37
+ dateCreated: '',
38
+ datePublished: '',
39
+ license: '',
40
+ tags: [],
41
+ },
42
+ curation: {
43
+ numVotes: 0,
44
+ rating: 0,
45
+ schema: '',
46
+ isListed: true,
47
+ },
48
+ };
49
+ registry;
50
+ constructor(ddo = {}) {
51
+ Object.assign(this, ddo, {
52
+ created: (ddo && ddo.created) || new Date().toISOString().replace(/\.[0-9]{3}/, ''),
53
+ });
54
+ }
55
+ }
56
+ export class AgentDDO extends DDO {
57
+ registry = {
58
+ owner: '0x',
59
+ creator: '0x',
60
+ url: '',
61
+ lastUpdated: 0n,
62
+ plans: [],
63
+ };
64
+ constructor(ddo = {}) {
65
+ super(ddo);
66
+ }
67
+ static getInstance(userId, userAddress, appId) {
68
+ return new AgentDDO({
69
+ id: '',
70
+ _nvm: { userId, userAddress, appId: appId || '', versions: [] },
71
+ registry: { owner: '0x', creator: '0x', url: '', lastUpdated: 0n, plans: [] },
72
+ });
73
+ }
74
+ }
75
+ export class PlanDDO extends DDO {
76
+ registry = {
77
+ owner: '0x',
78
+ price: {},
79
+ credits: {},
80
+ lastUpdated: 0n,
81
+ };
82
+ constructor(ddo = {}) {
83
+ super(ddo);
84
+ }
85
+ static getInstance(userId, userAddress, appId) {
86
+ return new PlanDDO({
87
+ id: '',
88
+ _nvm: { userId, userAddress, appId: appId || '', versions: [] },
89
+ registry: {
90
+ owner: '0x',
91
+ price: {},
92
+ credits: {},
93
+ lastUpdated: 0n,
94
+ },
95
+ });
96
+ }
97
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DDO.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/ddo/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './DDO.js';
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Generic API response wrapper used across all Nevermined API endpoints.
4
+ * This schema is shared between backend and frontend.
5
+ *
6
+ * @template T - The Zod schema for the data returned in the response
7
+ *
8
+ * @example
9
+ * // Backend usage in controller
10
+ * const responseSchema = NvmAPIResultSchema(CreateOrganizationResponseDataSchema)
11
+ * const result = {
12
+ * success: true,
13
+ * message: 'Organization created',
14
+ * httpStatus: 201,
15
+ * data: { organization, adminMember }
16
+ * }
17
+ *
18
+ * @example
19
+ * // Frontend usage
20
+ * const response = await api.post('/api/v1/organizations')
21
+ * const parsed = NvmAPIResultSchema(CreateOrganizationResponseDataSchema).parse(response)
22
+ * if (parsed.success) {
23
+ * console.log(parsed.data?.organization)
24
+ * }
25
+ */
26
+ export declare const NvmAPIResultSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodObject<{
27
+ success: z.ZodBoolean;
28
+ message: z.ZodOptional<z.ZodString>;
29
+ txHash: z.ZodOptional<z.ZodString>;
30
+ httpStatus: z.ZodOptional<z.ZodNumber>;
31
+ data: z.ZodOptional<T>;
32
+ when: z.ZodOptional<z.ZodDate>;
33
+ }, z.core.$strip>;
34
+ /**
35
+ * Type-safe interface inferred from the Zod schema
36
+ * @template T - The type of data returned in the response
37
+ */
38
+ export type NvmAPIResult<T = unknown> = {
39
+ success: boolean;
40
+ message?: string;
41
+ txHash?: string;
42
+ httpStatus?: number;
43
+ data?: T;
44
+ when?: Date;
45
+ };
46
+ //# sourceMappingURL=ApiResponseTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiResponseTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ApiResponseTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;;;;;;;iBAcpE,CAAA;AAEJ;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Generic API response wrapper used across all Nevermined API endpoints.
4
+ * This schema is shared between backend and frontend.
5
+ *
6
+ * @template T - The Zod schema for the data returned in the response
7
+ *
8
+ * @example
9
+ * // Backend usage in controller
10
+ * const responseSchema = NvmAPIResultSchema(CreateOrganizationResponseDataSchema)
11
+ * const result = {
12
+ * success: true,
13
+ * message: 'Organization created',
14
+ * httpStatus: 201,
15
+ * data: { organization, adminMember }
16
+ * }
17
+ *
18
+ * @example
19
+ * // Frontend usage
20
+ * const response = await api.post('/api/v1/organizations')
21
+ * const parsed = NvmAPIResultSchema(CreateOrganizationResponseDataSchema).parse(response)
22
+ * if (parsed.success) {
23
+ * console.log(parsed.data?.organization)
24
+ * }
25
+ */
26
+ export const NvmAPIResultSchema = (dataSchema) => z.object({
27
+ /** Whether the operation was successful */
28
+ success: z.boolean(),
29
+ /** Human-readable message describing the result */
30
+ message: z.string().optional(),
31
+ /** Transaction hash (for blockchain operations) */
32
+ txHash: z.string().optional(),
33
+ /** HTTP status code */
34
+ httpStatus: z.number().optional(),
35
+ /** The response payload - typed based on the endpoint */
36
+ data: dataSchema.optional(),
37
+ /** Timestamp of when the response was generated */
38
+ when: z.date().optional(),
39
+ });
@@ -0,0 +1,90 @@
1
+ import { Address } from 'viem';
2
+ export declare enum RedemptionType {
3
+ ONLY_GLOBAL_ROLE = 0,
4
+ ONLY_OWNER = 1,
5
+ ONLY_PLAN_ROLE = 2,
6
+ OWNER_OR_GLOBAL_ROLE = 3,
7
+ ONLY_SUBSCRIBER = 4
8
+ }
9
+ export interface DIDAgent {
10
+ owner: Address;
11
+ creator: Address;
12
+ url: string;
13
+ lastUpdated: bigint;
14
+ plans: bigint[];
15
+ }
16
+ export interface PriceConfig {
17
+ /**
18
+ * @notice Indicates if the price is in cryptocurrency (true) or fiat currency (false)
19
+ */
20
+ isCrypto: boolean;
21
+ /**
22
+ * @notice Indicates if the price is in cryptocurrency (true) or fiat currency (false)
23
+ */
24
+ tokenAddress?: Address;
25
+ /**
26
+ * The amounts to be paid for the plan
27
+ * @notice only if the price is not calculated by a smart contract
28
+ */
29
+ amounts: bigint[];
30
+ /**
31
+ * The receivers of the payments of the plan
32
+ * @notice only if the price is not calculated by a smart contract
33
+ */
34
+ receivers: string[];
35
+ /**
36
+ * The address of the smart contract that calculates the price
37
+ */
38
+ externalPriceAddress?: Address;
39
+ /**
40
+ * The address of the fee controller contract, if any
41
+ * @notice if not given, the fee controller is the default one
42
+ */
43
+ feeController?: Address;
44
+ /**
45
+ * @notice The template contract address associated with the plan
46
+ */
47
+ templateAddress?: Address;
48
+ }
49
+ export interface CreditsConfig {
50
+ /**
51
+ * @notice Indicates if the redemption amount is fixed (true) or dynamic (false)
52
+ */
53
+ isRedemptionAmountFixed: boolean;
54
+ /**
55
+ * How the credits can be redeemed
56
+ */
57
+ redemptionType: RedemptionType;
58
+ /**
59
+ * Whether the credits burn proof signed by the user is required
60
+ */
61
+ proofRequired: boolean;
62
+ /**
63
+ * The duration of the credits in seconds
64
+ */
65
+ durationSecs: bigint;
66
+ /**
67
+ * The amount of credits that are granted when purchasing the plan
68
+ */
69
+ amount: bigint;
70
+ /**
71
+ * The minimum number of credits redeemed when using the plan
72
+ */
73
+ minAmount: bigint;
74
+ /**
75
+ * The maximum number of credits redeemed when using the plan
76
+ * @notice only if isRedemptionAmountFixed is false
77
+ */
78
+ maxAmount: bigint;
79
+ /**
80
+ * The address of the NFT contract that represents the plan's credits
81
+ */
82
+ nftAddress?: Address;
83
+ }
84
+ export declare class Plan {
85
+ owner: Address;
86
+ price: PriceConfig;
87
+ credits: CreditsConfig;
88
+ lastUpdated: bigint;
89
+ }
90
+ //# sourceMappingURL=ContractsTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractsTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ContractsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAS9B,oBAAY,cAAc;IACxB,gBAAgB,IAAA;IAChB,UAAU,IAAA;IACV,cAAc,IAAA;IACd,oBAAoB,IAAA;IACpB,eAAe,IAAA;CAChB;AAED,MAAM,WAAW,QAAQ;IAEvB,KAAK,EAAE,OAAO,CAAA;IAEd,OAAO,EAAE,OAAO,CAAA;IAEhB,GAAG,EAAE,MAAM,CAAA;IAEX,WAAW,EAAE,MAAM,CAAA;IAEnB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAGD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAGD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,uBAAuB,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,cAAc,EAAE,cAAc,CAAA;IAC9B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAGD,qBAAa,IAAI;IAEf,KAAK,EAAE,OAAO,CAAA;IAEd,KAAK,EAAE,WAAW,CAAA;IAElB,OAAO,EAAE,aAAa,CAAA;IAEtB,WAAW,EAAE,MAAM,CAAA;CACpB"}
@@ -0,0 +1,26 @@
1
+ /// Different types of redemptions criterias that can be used when redeeming credits
2
+ /// @notice 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER
3
+ /// If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`
4
+ /// If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan
5
+ /// If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan
6
+ /// If OWNER_OR_GLOBAL_ROLE means Only the owner OR accounts with CREDITS_BURNER_ROLE can redeem
7
+ /// If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem
8
+ export var RedemptionType;
9
+ (function (RedemptionType) {
10
+ RedemptionType[RedemptionType["ONLY_GLOBAL_ROLE"] = 0] = "ONLY_GLOBAL_ROLE";
11
+ RedemptionType[RedemptionType["ONLY_OWNER"] = 1] = "ONLY_OWNER";
12
+ RedemptionType[RedemptionType["ONLY_PLAN_ROLE"] = 2] = "ONLY_PLAN_ROLE";
13
+ RedemptionType[RedemptionType["OWNER_OR_GLOBAL_ROLE"] = 3] = "OWNER_OR_GLOBAL_ROLE";
14
+ RedemptionType[RedemptionType["ONLY_SUBSCRIBER"] = 4] = "ONLY_SUBSCRIBER";
15
+ })(RedemptionType || (RedemptionType = {}));
16
+ /// Definition of a plan
17
+ export class Plan {
18
+ // The owner of the Plan
19
+ owner;
20
+ // The price configuration of the plan
21
+ price;
22
+ // The credits configuration of the plan
23
+ credits;
24
+ // The timestamp of the last time the plan definition was updated
25
+ lastUpdated;
26
+ }
@@ -0,0 +1,134 @@
1
+ import { CreditsConfig, PriceConfig } from './ContractsTypes.js';
2
+ export interface Metadata {
3
+ serviceEndpoint: string;
4
+ main: MetadataMainAttributes;
5
+ agent?: AgentMetadata;
6
+ additionalInformation?: unknown;
7
+ curation: Curation;
8
+ plan?: PlanMetadata;
9
+ }
10
+ export interface NvmConfigVersions {
11
+ id: number;
12
+ updated: string;
13
+ checksum: string;
14
+ }
15
+ export interface NvmConfig {
16
+ userId: string;
17
+ userAddress: string;
18
+ appId: string;
19
+ versions: NvmConfigVersions[];
20
+ }
21
+ export interface Proof {
22
+ created: string;
23
+ creator: string;
24
+ signatureValue: string;
25
+ type: string;
26
+ }
27
+ export interface MetadataMainAttributes {
28
+ name: string;
29
+ description?: string;
30
+ author?: string;
31
+ dateCreated?: string;
32
+ datePublished?: string;
33
+ license?: string;
34
+ tags?: string[];
35
+ }
36
+ /**
37
+ * Interface describing an asset of type `service`
38
+ */
39
+ export interface AgentMetadata {
40
+ /**
41
+ * Type of Web service
42
+ */
43
+ apiType?: 'restful' | 'graphql' | 'rpc' | 'other';
44
+ /**
45
+ * Authentication required by the API
46
+ */
47
+ authentication?: ResourceAuthentication;
48
+ /**
49
+ * List of endpoints of the API exposed by the Agent
50
+ */
51
+ endpoints?: ApiEndpoint[];
52
+ /**
53
+ * List of open endpoints available for the agent. These endpoints are not protected.
54
+ * This attribute is useful to indicate which endpoints are available for public access (documentation, definitions, etc).
55
+ */
56
+ openEndpoints?: string[];
57
+ requiredHeaders?: {
58
+ [verb: string]: string;
59
+ }[];
60
+ encryptedAttributes?: string;
61
+ }
62
+ export interface PlanMetadata {
63
+ isTrialPlan?: boolean;
64
+ productId?: string;
65
+ priceId?: string;
66
+ recurringSubscription?: boolean;
67
+ accessLimit: 'credits' | 'time';
68
+ fiatPaymentProvider?: 'stripe' | 'braintree';
69
+ }
70
+ export interface AgentRegistry {
71
+ owner: string;
72
+ creator: string;
73
+ url: string;
74
+ lastUpdated: string;
75
+ plans: string[];
76
+ }
77
+ export interface PlanRegistry {
78
+ owner: string;
79
+ lastUpdated: string;
80
+ price: PriceConfig;
81
+ credits: CreditsConfig;
82
+ }
83
+ export interface ResourceAuthentication {
84
+ type: ApiAuthenticationType;
85
+ user?: string;
86
+ password?: string;
87
+ token?: string;
88
+ encrypted?: boolean;
89
+ privateParameters?: {
90
+ [name: string]: string;
91
+ }[];
92
+ }
93
+ /**
94
+ * Curation attributes of Assets Metadata.
95
+ * @see https://github.com/nevermined-io/docs/blob/master/docs/architecture/specs/metadata/README.md#curation-attributes
96
+ */
97
+ export interface Curation {
98
+ /**
99
+ * Decimal value between 0 and 1. 0 is the default value.
100
+ * @example 0.93
101
+ */
102
+ rating: number;
103
+ /**
104
+ * Number of votes. 0 is the default value.
105
+ * @example 123
106
+ */
107
+ numVotes: number;
108
+ /**
109
+ * Schema applied to calculate the rating.
110
+ * @example "Binary Voting"
111
+ */
112
+ schema?: string;
113
+ /**
114
+ * Flag unsuitable content.
115
+ * @example true
116
+ */
117
+ isListed?: boolean;
118
+ }
119
+ export declare enum ApiAuthenticationType {
120
+ none = "none",
121
+ basic = "basic",
122
+ bearer = "bearer",
123
+ oauth = "oauth"
124
+ }
125
+ export type ApiEndpoint = {
126
+ [verb: string]: string;
127
+ };
128
+ export declare enum AgentTaskStatus {
129
+ SUCCESS = "Success",
130
+ FAILURE = "Failure",
131
+ PENDING = "Pending",
132
+ IN_PROGRESS = "In_Progress"
133
+ }
134
+ //# sourceMappingURL=DDOTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DDOTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/types/DDOTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,eAAe,EAAE,MAAM,C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AY,qBAAqB;IAC/B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAEpD,oBAAY,eAAe;IACzB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,WAAW,gBAAgB;CAC5B"}
@@ -0,0 +1,14 @@
1
+ export var ApiAuthenticationType;
2
+ (function (ApiAuthenticationType) {
3
+ ApiAuthenticationType["none"] = "none";
4
+ ApiAuthenticationType["basic"] = "basic";
5
+ ApiAuthenticationType["bearer"] = "bearer";
6
+ ApiAuthenticationType["oauth"] = "oauth";
7
+ })(ApiAuthenticationType || (ApiAuthenticationType = {}));
8
+ export var AgentTaskStatus;
9
+ (function (AgentTaskStatus) {
10
+ AgentTaskStatus["SUCCESS"] = "Success";
11
+ AgentTaskStatus["FAILURE"] = "Failure";
12
+ AgentTaskStatus["PENDING"] = "Pending";
13
+ AgentTaskStatus["IN_PROGRESS"] = "In_Progress";
14
+ })(AgentTaskStatus || (AgentTaskStatus = {}));
@@ -0,0 +1,28 @@
1
+ export interface Balance {
2
+ eth: bigint;
3
+ nevermined: bigint;
4
+ }
5
+ export interface Eip712Data {
6
+ message: string;
7
+ chainId: number;
8
+ }
9
+ export interface TypedDataDomain {
10
+ name: string;
11
+ version: string;
12
+ chainId: number;
13
+ }
14
+ export interface TypedDataTypes {
15
+ Nevermined: {
16
+ name: string;
17
+ type: string;
18
+ }[];
19
+ }
20
+ export interface PriceBreakdown {
21
+ grossCharge: bigint;
22
+ ownerMargin: bigint;
23
+ nvmMargin: bigint;
24
+ stripeFee?: bigint;
25
+ nvmCharge: bigint;
26
+ orgMargin?: bigint;
27
+ }
28
+ //# sourceMappingURL=GeneralTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeneralTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/types/GeneralTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;KACb,EAAE,CAAA;CACJ;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1 @@
1
+ export {};