@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
@@ -0,0 +1,149 @@
1
+ import { CreditsConfig, PriceConfig } from './ContractsTypes.js'
2
+
3
+ export interface Metadata {
4
+ serviceEndpoint: string
5
+ main: MetadataMainAttributes
6
+ agent?: AgentMetadata
7
+ additionalInformation?: unknown
8
+ curation: Curation
9
+ plan?: PlanMetadata
10
+ }
11
+
12
+ export interface NvmConfigVersions {
13
+ id: number
14
+ updated: string
15
+ checksum: string
16
+ }
17
+ export interface NvmConfig {
18
+ userId: string
19
+ userAddress: string
20
+ appId: string
21
+ versions: NvmConfigVersions[]
22
+ }
23
+
24
+ export interface Proof {
25
+ created: string
26
+ creator: string
27
+ signatureValue: string
28
+ type: string
29
+ }
30
+
31
+ export interface MetadataMainAttributes {
32
+ name: string
33
+ description?: string
34
+ author?: string
35
+ dateCreated?: string
36
+ datePublished?: string
37
+ license?: string
38
+ tags?: string[]
39
+ }
40
+
41
+ /**
42
+ * Interface describing an asset of type `service`
43
+ */
44
+ export interface AgentMetadata {
45
+ /**
46
+ * Type of Web service
47
+ */
48
+ apiType?: 'restful' | 'graphql' | 'rpc' | 'other'
49
+
50
+ /**
51
+ * Authentication required by the API
52
+ */
53
+ authentication?: ResourceAuthentication
54
+
55
+ /**
56
+ * List of endpoints of the API exposed by the Agent
57
+ */
58
+ endpoints?: ApiEndpoint[]
59
+
60
+ /**
61
+ * List of open endpoints available for the agent. These endpoints are not protected.
62
+ * This attribute is useful to indicate which endpoints are available for public access (documentation, definitions, etc).
63
+ */
64
+ openEndpoints?: string[]
65
+
66
+ requiredHeaders?: { [verb: string]: string }[]
67
+
68
+ encryptedAttributes?: string
69
+ }
70
+
71
+ export interface PlanMetadata {
72
+ isTrialPlan?: boolean
73
+ productId?: string
74
+ priceId?: string
75
+ recurringSubscription?: boolean
76
+ accessLimit: 'credits' | 'time'
77
+ fiatPaymentProvider?: 'stripe' | 'braintree'
78
+ }
79
+
80
+ export interface AgentRegistry {
81
+ owner: string
82
+ creator: string
83
+ url: string
84
+ lastUpdated: string
85
+ plans: string[]
86
+ }
87
+
88
+ export interface PlanRegistry {
89
+ owner: string
90
+ lastUpdated: string
91
+ price: PriceConfig
92
+ credits: CreditsConfig
93
+ }
94
+
95
+ export interface ResourceAuthentication {
96
+ type: ApiAuthenticationType
97
+
98
+ user?: string
99
+ password?: string
100
+ token?: string
101
+ encrypted?: boolean
102
+ privateParameters?: { [name: string]: string }[]
103
+ }
104
+
105
+ /**
106
+ * Curation attributes of Assets Metadata.
107
+ * @see https://github.com/nevermined-io/docs/blob/master/docs/architecture/specs/metadata/README.md#curation-attributes
108
+ */
109
+ export interface Curation {
110
+ /**
111
+ * Decimal value between 0 and 1. 0 is the default value.
112
+ * @example 0.93
113
+ */
114
+ rating: number
115
+
116
+ /**
117
+ * Number of votes. 0 is the default value.
118
+ * @example 123
119
+ */
120
+ numVotes: number
121
+
122
+ /**
123
+ * Schema applied to calculate the rating.
124
+ * @example "Binary Voting"
125
+ */
126
+ schema?: string
127
+
128
+ /**
129
+ * Flag unsuitable content.
130
+ * @example true
131
+ */
132
+ isListed?: boolean
133
+ }
134
+
135
+ export enum ApiAuthenticationType {
136
+ none = 'none',
137
+ basic = 'basic',
138
+ bearer = 'bearer',
139
+ oauth = 'oauth',
140
+ }
141
+
142
+ export type ApiEndpoint = { [verb: string]: string }
143
+
144
+ export enum AgentTaskStatus {
145
+ SUCCESS = 'Success',
146
+ FAILURE = 'Failure',
147
+ PENDING = 'Pending',
148
+ IN_PROGRESS = 'In_Progress',
149
+ }
@@ -0,0 +1,31 @@
1
+ export interface Balance {
2
+ eth: bigint
3
+ nevermined: bigint
4
+ }
5
+
6
+ export interface Eip712Data {
7
+ message: string
8
+ chainId: number
9
+ }
10
+
11
+ export interface TypedDataDomain {
12
+ name: string
13
+ version: string
14
+ chainId: number
15
+ }
16
+
17
+ export interface TypedDataTypes {
18
+ Nevermined: {
19
+ name: string
20
+ type: string
21
+ }[]
22
+ }
23
+
24
+ export interface PriceBreakdown {
25
+ grossCharge: bigint
26
+ ownerMargin: bigint
27
+ nvmMargin: bigint
28
+ stripeFee?: bigint
29
+ nvmCharge: bigint
30
+ orgMargin?: bigint
31
+ }
@@ -0,0 +1,145 @@
1
+ import { DDO } from '../ddo/DDO.js'
2
+
3
+ /**
4
+ * It described the policy to be used when resolving an asset. It has the following options:
5
+ * * ImmutableFirst - It checks if there is a reference to an immutable data-store (IPFS, Filecoin, etc) on-chain. If that's the case uses the URL to resolve the Metadata. If not try to resolve the metadata using the URL of the Metadata/Marketplace API
6
+ * * MetadataAPIFirst - Try to resolve the metadata from the Marketplace/Metadata API, if it can't tries to resolve using the immutable url
7
+ * * OnlyImmutable - Try to resolve the metadata only from the immutable data store URL
8
+ * * OnlyMetadataAPI - Try to resolve the metadata only from the Metadata API. It gets the metadata api url from the DIDRegistry
9
+ * * NoRegisry - Gets the metadata from the Metadata API using as endpoint the metadata api url from the SDK config. This method don't gets any on-chain information because assumes the DID is not registered on-chain
10
+ */
11
+ export enum DIDResolvePolicy {
12
+ ImmutableFirst = 0,
13
+ MetadataAPIFirst = 1,
14
+ OnlyImmutable = 2,
15
+ OnlyMetadataAPI = 3,
16
+ NoRegistry = 4,
17
+ }
18
+
19
+ /**
20
+ * Where the metadata will be published. Options:
21
+ * - OnlyMetadataAPI, The metadata will be stored only in the Metadata/Marketplace API
22
+ * - IPFS, The metadata will be stored in the Metadata/Marketplace API and IPFS
23
+ * - Filecoin, The metadata will be stored in the Metadata/Marketplace API and Filecoin
24
+ * - Arweave, The metadata will be stored in the Metadata/Marketplace API and Arweave
25
+ */
26
+ export enum PublishMetadataOptions {
27
+ OnlyMetadataAPI = 0,
28
+ IPFS = 1,
29
+ Filecoin = 2,
30
+ Arweave = 3,
31
+ }
32
+
33
+ /**
34
+ * It specifies if the DID will be published on-chain initially or not.
35
+ */
36
+ export enum PublishOnChainOptions {
37
+ DIDRegistry = 0, // The DID and the reference to the DDO will be stored in the DIDRegistry contract
38
+ OnlyOffchain = 1, // THE DID won't be stored on-chain and will be lazy-registered when needed
39
+ }
40
+
41
+ export class AssetPublicationOptions {
42
+ metadata?: PublishMetadataOptions = PublishMetadataOptions.OnlyMetadataAPI
43
+ did?: PublishOnChainOptions = PublishOnChainOptions.DIDRegistry
44
+ }
45
+
46
+ export interface SearchResults {
47
+ value: number
48
+ relation: 'eq' | 'gte'
49
+ }
50
+
51
+ export interface QueryResult {
52
+ results: DDO[]
53
+ page: number
54
+ totalPages: number
55
+ totalResults: { [jsonPath: string]: any }
56
+ }
57
+
58
+ export interface MarketplaceResults<Entity> {
59
+ page: number
60
+ results: Entity[]
61
+ total_pages: number
62
+ total_results: SearchResults
63
+ }
64
+
65
+ export interface SearchQuery {
66
+ offset?: number
67
+ page?: number
68
+ text?: string
69
+ query?: unknown
70
+ sort?: unknown
71
+ show_unlisted?: boolean
72
+ appId?: string
73
+ }
74
+
75
+ export enum PermissionType {
76
+ Read = 'read',
77
+ Update = 'update',
78
+ Delete = 'delete',
79
+ Admin = 'admin',
80
+ }
81
+
82
+ export interface NewPermission {
83
+ userId: string
84
+ type: PermissionType[]
85
+ issuer: string
86
+ holder: string
87
+ }
88
+
89
+ export interface Permission extends NewPermission {
90
+ id: string
91
+ issuanceDate: Date
92
+ }
93
+
94
+ export enum PaymentMethodsAccepted {
95
+ Crypto = 'crypto',
96
+ Fiat = 'fiat',
97
+ All = 'all',
98
+ NotSelected = 'notSelected',
99
+ }
100
+
101
+ export enum State {
102
+ Disabled = 'disabled',
103
+ Unconfirmed = 'unconfirmed',
104
+ Confirmed = 'confirmed',
105
+ }
106
+
107
+ export interface Stripe {
108
+ accountId?: string | null
109
+ isAccountValidated?: boolean
110
+ accountCreatedAt?: string
111
+ accountUpdatedAt?: string
112
+ additionalInformation?: unknown
113
+ }
114
+
115
+ export interface AdditionalInformation {
116
+ privyUserId?: string
117
+ privyWalletId?: string
118
+ }
119
+
120
+ export interface NewProfile {
121
+ isListed: boolean
122
+ state: State
123
+ addresses: string[]
124
+ nickname: string
125
+ name?: string
126
+ email?: string
127
+ live?: Stripe
128
+ sandbox?: Stripe
129
+ paymentCountry?: string
130
+ additionalInformation?: unknown
131
+ }
132
+
133
+ export interface Profile extends NewProfile {
134
+ userId: string
135
+ creationDate: Date
136
+ updateDate: Date
137
+ }
138
+
139
+ export interface ReducedProfile {
140
+ userId: string
141
+ nickname?: string
142
+ live?: Stripe
143
+ sandbox?: Stripe
144
+ additionalInformation?: unknown
145
+ }
@@ -0,0 +1,29 @@
1
+ export enum Flavor {
2
+ Avatar = 0,
3
+ Cover = 1,
4
+ Animation = 2,
5
+ Image = 3,
6
+ Video = 4,
7
+ Audio = 5,
8
+ Terms = 6,
9
+ Private = 7,
10
+ SampleData = 8,
11
+ }
12
+
13
+ export enum FlavorFolder {
14
+ Avatars = 'avatars',
15
+ Covers = 'covers',
16
+ Animations = 'animations',
17
+ Images = 'images',
18
+ Videos = 'videos',
19
+ Audios = 'audios',
20
+ Terms = 'terms',
21
+ Privates = 'private',
22
+ SampleData = 'sample-data',
23
+ }
24
+
25
+ export enum TranscodingStatus {
26
+ Pending = 'Pending',
27
+ Done = 'Done',
28
+ Error = 'Error',
29
+ }
@@ -0,0 +1,6 @@
1
+ export * from './ContractsTypes.js'
2
+ export * from './DDOTypes.js'
3
+ export * from './GeneralTypes.js'
4
+ export * from './MetadataTypes.js'
5
+ export * from './TranscoderTypes.js'
6
+ export * from './types.js'
@@ -0,0 +1,264 @@
1
+ import * as jose from 'jose'
2
+
3
+ export enum AuthRoles {
4
+ Admin = 'admin',
5
+ }
6
+
7
+ export interface AuthUser {
8
+ userId: string
9
+ address: string
10
+ hash: string
11
+ roles?: AuthRoles[]
12
+ nvmApiKey?: jose.JWTPayload
13
+ }
14
+
15
+ export interface Request<G> {
16
+ hostname: string
17
+ body?: G
18
+ query?: G
19
+ params?: G
20
+ client: { localPort: number }
21
+ protocol: string
22
+ url: string
23
+ user?: AuthUser
24
+ }
25
+
26
+ export type DistinctPlans = {
27
+ page: number
28
+ totalPages: number
29
+ totalResults: number
30
+ results: any[]
31
+ }
32
+
33
+ export enum PointsRulesCategory {
34
+ wau = 'wau',
35
+ supply = 'supply',
36
+ purchases = 'purchases',
37
+ demand = 'demand',
38
+ curation = 'curation',
39
+ network = 'network',
40
+ other = 'other',
41
+ }
42
+
43
+ export enum PointsRulesRecurrency {
44
+ unlimitted = 'unlimitted',
45
+ timeslimitted = 'timeslimitted',
46
+ onlyonce = 'onlyonce',
47
+ onceperitem = 'onceperitem',
48
+ capday = 'capday',
49
+ capweek = 'capweek',
50
+ capmonth = 'capmonth',
51
+ capyear = 'capyear',
52
+ other = 'other',
53
+ }
54
+
55
+ export enum PointsEventStatus {
56
+ Pending = 'Pending',
57
+ Processed = 'Processed',
58
+ Failed = 'Failed',
59
+ Skipped = 'Skipped',
60
+ Other = 'Other',
61
+ }
62
+
63
+ export enum NotificationType {
64
+ SubscriptionReceived = 'SubscriptionReceived',
65
+ SubscriptionPurchased = 'SubscriptionPurchased',
66
+ AccountSetup = 'AccountSetup',
67
+ EmailValidation = 'EmailValidation',
68
+ Other = 'Other',
69
+ }
70
+
71
+ export enum NotificationOriginator {
72
+ Nevermined = 'Nevermined',
73
+ Other = 'Other',
74
+ }
75
+
76
+ export enum NotificationReadStatus {
77
+ Pending = 'Pending',
78
+ Read = 'Read',
79
+ Deleted = 'Deleted',
80
+ Other = 'Other',
81
+ }
82
+
83
+ export enum NotificationDeliveryStatus {
84
+ Pending = 'Pending',
85
+ Sent = 'Sent',
86
+ Failed = 'Failed',
87
+ NotRequired = 'NotRequired',
88
+ Skipped = 'Skipped',
89
+ Other = 'Other',
90
+ }
91
+
92
+ export enum EmailChallengeStatus {
93
+ Pending = 'Pending',
94
+ Validated = 'Validated',
95
+ Failed = 'Failed',
96
+ }
97
+
98
+ export enum PlanTransactionType {
99
+ Purchase = 'Purchase',
100
+ Mint = 'Mint',
101
+ Burn = 'Burn',
102
+ Transfer = 'Transfer',
103
+ Error = 'Error',
104
+ Other = 'Other',
105
+ }
106
+
107
+ export enum PlanTransactionPaymentType {
108
+ Crypto = 'Crypto',
109
+ Fiat = 'Fiat',
110
+ }
111
+
112
+ export enum CheckoutSessionType {
113
+ embedded = 'embedded',
114
+ redirect = 'redirect',
115
+ }
116
+
117
+ export enum WidgetLayout {
118
+ Horizontal = 'Horizontal',
119
+ Vertical = 'Vertical',
120
+ Reduced = 'Reduced',
121
+ }
122
+
123
+ export enum StripeEventStatus {
124
+ Pending = 'Pending',
125
+ Done = 'Done',
126
+ Error = 'Error',
127
+ Ignored = 'Ignored',
128
+ Other = 'Other',
129
+ }
130
+
131
+ export enum ResultType {
132
+ matrix = 'matrix',
133
+ vector = 'vector',
134
+ scalar = 'scalar',
135
+ string = 'string',
136
+ }
137
+
138
+ export enum ApiKeyTxType {
139
+ NewPlan = 'NewPlan',
140
+ NewAgent = 'NewAgent',
141
+ EditPlan = 'EditPlan',
142
+ EditAgent = 'EditAgent',
143
+ Purchase = 'Purchase',
144
+ Download = 'Download',
145
+ AccessHit = 'AccessHit',
146
+ Mint = 'Mint',
147
+ Burn = 'Burn',
148
+ AgentExecution = 'AgentExecution',
149
+ Other = 'Other',
150
+ }
151
+
152
+ export interface Metric {
153
+ consumer: string
154
+ did: string
155
+ endpoint: string
156
+ job: string
157
+ namespace: string
158
+ owner: string
159
+ access_date: Date
160
+ }
161
+
162
+ export interface AccessHistory {
163
+ date: string
164
+ owner: string
165
+ consumer: string
166
+ endpoint: string
167
+ }
168
+
169
+ export interface LineItem {
170
+ planId: string
171
+ currency: string
172
+ name: string
173
+ price: number
174
+ quantity: number
175
+ description?: string
176
+ imageUrl?: string
177
+ }
178
+
179
+ export interface StripeLineItem {
180
+ price_data: {
181
+ currency: string
182
+ product_data: {
183
+ name: string
184
+ description?: string
185
+ images?: string[]
186
+ metadata?: [string, string]
187
+ }
188
+ unit_amount_decimal: number
189
+ }
190
+ quantity: number
191
+ }
192
+
193
+ export const DEFAULT_PAGE = 1
194
+ export const DEFAULT_OFFSET = 10_000
195
+
196
+ export interface PaginationOptions {
197
+ page: number
198
+ skip: number
199
+ offset: number
200
+ sortBy?: string
201
+ sortOrder?: 'asc' | 'desc'
202
+ }
203
+
204
+ export enum TaskLogLevel {
205
+ debug = 'debug',
206
+ info = 'info',
207
+ warn = 'warn',
208
+ error = 'error',
209
+ }
210
+
211
+ export enum PaymentPlanTypes {
212
+ expirable = 'expirable',
213
+ credits = 'credits',
214
+ }
215
+
216
+ export interface OrderResult {
217
+ txHash: `0x${string}`
218
+ planId: bigint
219
+ planReceiver: `0x${string}`
220
+ currency: string
221
+ totalAmount: bigint
222
+ numCredits: bigint
223
+ paymentMethod: PlanTransactionPaymentType
224
+ tokenAddress?: `0x${string}`
225
+ }
226
+
227
+ export const NVM_USERID_HEADER = 'NVM-User-id'
228
+ export const NVM_COST_HEADER = 'NVMCreditsConsumed'
229
+ export const DEFAULT_COST_CREDITS = '1'
230
+
231
+ export enum OrganizationType {
232
+ Free = 'Free',
233
+ Premium = 'Premium',
234
+ Enterprise = 'Enterprise',
235
+ Other = 'Other',
236
+ }
237
+
238
+ export enum OrganizationMemberRole {
239
+ Admin = 'Admin',
240
+ Member = 'Member',
241
+ }
242
+
243
+ export interface Branding {
244
+ // Theme name (e.g., 'default', 'gradient', 'dark', 'ocean', 'sunset', 'custom')
245
+ themeName?: string
246
+
247
+ // Company logo
248
+ logo?: string
249
+
250
+ // Left panel colors
251
+ leftPanelHeadingTextColor?: string
252
+ leftPanelBodyTextColor?: string
253
+ leftPanelBackgroundColor1?: string
254
+ leftPanelBackgroundColor2?: string
255
+ leftPanelBackgroundImageUrl?: string // Alternative to background colors
256
+
257
+ // Right card colors
258
+ rightCardTextColor?: string
259
+ rightCardButtonBackgroundColor?: string
260
+ rightCardButtonTextColor?: string
261
+ rightCardBackgroundColor1?: string
262
+ rightCardBackgroundColor2?: string
263
+ rightCardBackgroundImageUrl?: string // Alternative to background colors
264
+ }