@calmlens/js-sdk 0.0.0 → 0.0.2
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/README.md +190 -22
- package/cjs/ApiKey.d.ts +31 -0
- package/cjs/ApiKey.js +59 -0
- package/cjs/Asset.d.ts +83 -3
- package/cjs/Asset.js +198 -28
- package/cjs/Auth.d.ts +95 -0
- package/cjs/Auth.js +2 -0
- package/cjs/CalmLensClient.d.ts +28 -11
- package/cjs/CalmLensClient.js +138 -77
- package/cjs/CalmLensTypes.d.ts +2 -0
- package/cjs/Classification.js +40 -7
- package/cjs/DocMetaTypes.d.ts +7 -0
- package/cjs/DocMetaTypes.js +7 -0
- package/cjs/Page.d.ts +42 -0
- package/cjs/Page.js +94 -0
- package/cjs/PublicApiSchemas.d.ts +1593 -0
- package/cjs/PublicApiSchemas.js +334 -0
- package/cjs/RequestInfo.d.ts +23 -0
- package/cjs/RequestInfo.js +2 -0
- package/cjs/Roles.d.ts +21 -0
- package/cjs/Roles.js +84 -0
- package/cjs/SharedConstants.d.ts +134 -0
- package/cjs/SharedConstants.js +125 -0
- package/cjs/SharedTypes.d.ts +6 -1
- package/cjs/User.d.ts +17 -0
- package/cjs/User.js +51 -0
- package/cjs/UtilTypes.d.ts +30 -0
- package/cjs/UtilTypes.js +4 -0
- package/cjs/Workflow.d.ts +58 -0
- package/cjs/Workflow.js +83 -0
- package/cjs/ZodUtils.d.ts +39 -0
- package/cjs/ZodUtils.js +328 -0
- package/cjs/index.js +4 -1
- package/esm/ApiKey.d.ts +31 -0
- package/esm/ApiKey.js +23 -0
- package/esm/Asset.d.ts +83 -3
- package/esm/Asset.js +148 -12
- package/esm/Auth.d.ts +95 -0
- package/esm/Auth.js +1 -0
- package/esm/CalmLensClient.d.ts +28 -11
- package/esm/CalmLensClient.js +104 -55
- package/esm/CalmLensTypes.d.ts +2 -0
- package/esm/Classification.js +1 -1
- package/esm/DocMetaTypes.d.ts +7 -0
- package/esm/DocMetaTypes.js +4 -0
- package/esm/Page.d.ts +42 -0
- package/esm/Page.js +55 -0
- package/esm/PublicApiSchemas.d.ts +1593 -0
- package/esm/PublicApiSchemas.js +298 -0
- package/esm/RequestInfo.d.ts +23 -0
- package/esm/RequestInfo.js +1 -0
- package/esm/Roles.d.ts +21 -0
- package/esm/Roles.js +45 -0
- package/esm/SharedConstants.d.ts +134 -0
- package/esm/SharedConstants.js +122 -0
- package/esm/SharedTypes.d.ts +6 -1
- package/esm/User.d.ts +17 -0
- package/esm/User.js +15 -0
- package/esm/UtilTypes.d.ts +30 -0
- package/esm/UtilTypes.js +1 -0
- package/esm/Workflow.d.ts +58 -0
- package/esm/Workflow.js +46 -0
- package/esm/ZodUtils.d.ts +39 -0
- package/esm/ZodUtils.js +266 -0
- package/package.json +10 -10
- package/cjs/SchemaUtils.d.ts +0 -11
- package/cjs/SchemaUtils.js +0 -63
- package/esm/SchemaUtils.d.ts +0 -11
- package/esm/SchemaUtils.js +0 -46
package/cjs/Asset.js
CHANGED
|
@@ -1,39 +1,209 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ASSET_SCHEMA = exports.ASSET_VISIBILITY_SCHEMA = exports.ASSET_TYPE_SCHEMA = exports.ASSET_STATUS_SCHEMA = void 0;
|
|
4
|
-
var zod = require("zod/v4");
|
|
36
|
+
exports.ASSET_SCHEMA = exports.PROCESSING_OPTIONS_SCHEMA = exports.DOCUMENT_DATA_SCHEMA = exports.IMAGE_DATA_SCHEMA = exports.CHECKSUMS_SCHEMA = exports.ASSET_VISIBILITY_SCHEMA = exports.isMultimediaDocumentMimeType = exports.MULTIMEDIA_DOCUMENT_MIME_TYPES = exports.ASSET_TYPE_SCHEMA = exports.ASSET_STATUS_SCHEMA = void 0;
|
|
37
|
+
var zod = __importStar(require("zod/v4"));
|
|
38
|
+
var zod_meta_1 = require("zod-meta");
|
|
5
39
|
var Classification_1 = require("./Classification");
|
|
6
|
-
var
|
|
40
|
+
var DocMetaTypes_1 = require("./DocMetaTypes");
|
|
41
|
+
var Workflow_1 = require("./Workflow");
|
|
42
|
+
var ZodUtils_1 = require("./ZodUtils");
|
|
7
43
|
exports.ASSET_STATUS_SCHEMA = zod.enum(["pending", "approved", "rejected", "error"]);
|
|
8
|
-
exports.ASSET_TYPE_SCHEMA = zod.enum([
|
|
44
|
+
exports.ASSET_TYPE_SCHEMA = zod.enum([
|
|
45
|
+
"image",
|
|
46
|
+
"video",
|
|
47
|
+
"audio",
|
|
48
|
+
"plaintext-document",
|
|
49
|
+
"multimedia-document",
|
|
50
|
+
"website",
|
|
51
|
+
"file",
|
|
52
|
+
]);
|
|
53
|
+
/**
|
|
54
|
+
* MIME types that are considered multimedia documents
|
|
55
|
+
* (documents that contain both text and embedded images/media)
|
|
56
|
+
*/
|
|
57
|
+
exports.MULTIMEDIA_DOCUMENT_MIME_TYPES = [
|
|
58
|
+
"application/pdf",
|
|
59
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // DOCX
|
|
60
|
+
"application/msword", // DOC
|
|
61
|
+
"application/rtf", // RTF
|
|
62
|
+
"application/vnd.oasis.opendocument.text", // ODT
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a MIME type is a multimedia document
|
|
66
|
+
*/
|
|
67
|
+
var isMultimediaDocumentMimeType = function (mimeType) {
|
|
68
|
+
return exports.MULTIMEDIA_DOCUMENT_MIME_TYPES.includes(mimeType);
|
|
69
|
+
};
|
|
70
|
+
exports.isMultimediaDocumentMimeType = isMultimediaDocumentMimeType;
|
|
9
71
|
exports.ASSET_VISIBILITY_SCHEMA = zod.enum(["public", "private"]);
|
|
10
|
-
exports.
|
|
11
|
-
|
|
12
|
-
|
|
72
|
+
exports.CHECKSUMS_SCHEMA = zod.object({
|
|
73
|
+
md5: zod.string().nullish(),
|
|
74
|
+
sha1: zod.string().nullish(),
|
|
75
|
+
sha256: zod.string().nullish(),
|
|
76
|
+
sha384: zod.string().nullish(),
|
|
77
|
+
sha512: zod.string().nullish(),
|
|
78
|
+
});
|
|
79
|
+
exports.IMAGE_DATA_SCHEMA = zod.object({
|
|
80
|
+
perceptualHash: zod.string().nullish(),
|
|
81
|
+
});
|
|
82
|
+
exports.DOCUMENT_DATA_SCHEMA = zod.object({});
|
|
83
|
+
exports.PROCESSING_OPTIONS_SCHEMA = zod
|
|
84
|
+
.object({
|
|
85
|
+
keepAfterProcessing: zod
|
|
86
|
+
.boolean()
|
|
87
|
+
.nullish()
|
|
88
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
89
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
90
|
+
description: "Whether to keep the asset after processing",
|
|
91
|
+
defaultValue: false,
|
|
92
|
+
}),
|
|
93
|
+
])),
|
|
94
|
+
image: zod
|
|
95
|
+
.object({
|
|
96
|
+
ocrEnabled: zod
|
|
97
|
+
.boolean()
|
|
98
|
+
.nullish()
|
|
99
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
100
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
101
|
+
description: "Whether to perform OCR on image assets or images extracted from multimedia documents and websites",
|
|
102
|
+
defaultValue: false,
|
|
103
|
+
}),
|
|
104
|
+
])),
|
|
105
|
+
})
|
|
106
|
+
.nullish(),
|
|
107
|
+
})
|
|
108
|
+
.nullish();
|
|
109
|
+
exports.ASSET_SCHEMA = zod
|
|
110
|
+
.object({
|
|
111
|
+
id: (0, ZodUtils_1.primaryUuidField)(),
|
|
112
|
+
projectId: (0, ZodUtils_1.uuidField)(),
|
|
13
113
|
sizeInBytes: zod.number().nullish(),
|
|
14
|
-
userId: (0,
|
|
15
|
-
parentId: (0,
|
|
16
|
-
createdAt: (0,
|
|
17
|
-
updatedAt: (0,
|
|
18
|
-
|
|
114
|
+
userId: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
115
|
+
parentId: (0, ZodUtils_1.uuidField)().nullish(),
|
|
116
|
+
createdAt: (0, ZodUtils_1.createdAtField)(),
|
|
117
|
+
updatedAt: (0, ZodUtils_1.updatedAtField)(),
|
|
118
|
+
checksums: exports.CHECKSUMS_SCHEMA.nullish(),
|
|
119
|
+
imageData: exports.IMAGE_DATA_SCHEMA.nullish(),
|
|
120
|
+
documentData: exports.DOCUMENT_DATA_SCHEMA.nullish(),
|
|
121
|
+
name: (0, ZodUtils_1.saneStringField)({
|
|
19
122
|
type: "large",
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
123
|
+
}).meta((0, zod_meta_1.metaStore)([
|
|
124
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
125
|
+
description: "Name of the asset",
|
|
126
|
+
placeholder: "my-image.jpg",
|
|
127
|
+
}),
|
|
128
|
+
])),
|
|
129
|
+
fileFormat: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
130
|
+
fileExtension: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
131
|
+
description: (0, ZodUtils_1.saneStringField)({
|
|
24
132
|
type: "large",
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
133
|
+
})
|
|
134
|
+
.nullish()
|
|
135
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
136
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
137
|
+
description: "Optional description of the asset",
|
|
138
|
+
placeholder: "A beautiful landscape image",
|
|
139
|
+
}),
|
|
140
|
+
])),
|
|
141
|
+
externalId: (0, ZodUtils_1.saneStringField)()
|
|
142
|
+
.nullish()
|
|
143
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
144
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
145
|
+
description: "External identifier for the asset",
|
|
146
|
+
placeholder: "ext-12345",
|
|
147
|
+
}),
|
|
148
|
+
])),
|
|
149
|
+
externalUrl: zod
|
|
150
|
+
.string()
|
|
151
|
+
.url()
|
|
152
|
+
.nullish()
|
|
153
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
154
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
155
|
+
description: "External URL associated with the asset",
|
|
156
|
+
placeholder: "https://example.com/asset",
|
|
157
|
+
}),
|
|
158
|
+
])),
|
|
159
|
+
previewImageId: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
160
|
+
storageId: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
161
|
+
averageColor: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
31
162
|
type: exports.ASSET_TYPE_SCHEMA,
|
|
32
|
-
previewHash: (0,
|
|
33
|
-
metadata: zod
|
|
34
|
-
|
|
163
|
+
previewHash: (0, ZodUtils_1.saneStringField)().nullish(),
|
|
164
|
+
metadata: zod
|
|
165
|
+
.any()
|
|
166
|
+
.nullish()
|
|
167
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
168
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
169
|
+
description: "Custom metadata for the asset",
|
|
170
|
+
}),
|
|
171
|
+
])),
|
|
172
|
+
tags: zod
|
|
173
|
+
.array((0, ZodUtils_1.saneStringField)())
|
|
174
|
+
.nullish()
|
|
175
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
176
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
177
|
+
description: "Array of tags for the asset",
|
|
178
|
+
placeholder: '["tag1", "tag2"]',
|
|
179
|
+
}),
|
|
180
|
+
])),
|
|
35
181
|
report: Classification_1.CLASSIFICATION_REPORT_SCHEMA.nullish(),
|
|
36
182
|
status: exports.ASSET_STATUS_SCHEMA,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
183
|
+
extractedTextId: (0, ZodUtils_1.saneStringField)()
|
|
184
|
+
.nullish()
|
|
185
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
186
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
187
|
+
description: "ID of the extracted text content stored in R2 (e.g., from OCR or text extraction)",
|
|
188
|
+
}),
|
|
189
|
+
])),
|
|
190
|
+
processingOptions: exports.PROCESSING_OPTIONS_SCHEMA,
|
|
191
|
+
visibility: exports.ASSET_VISIBILITY_SCHEMA.nullish().meta((0, zod_meta_1.metaStore)([
|
|
192
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
193
|
+
description: "Visibility level of the asset",
|
|
194
|
+
defaultValue: "private",
|
|
195
|
+
}),
|
|
196
|
+
])),
|
|
197
|
+
storageDeletedAt: zod.number().nullish(),
|
|
198
|
+
classificationWorkflow: Workflow_1.WORKFLOW_SCHEMA.nullish().meta((0, zod_meta_1.metaStore)([
|
|
199
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
200
|
+
description: "Workflow tracking the classification process for this asset",
|
|
201
|
+
}),
|
|
202
|
+
])),
|
|
203
|
+
})
|
|
204
|
+
.meta((0, zod_meta_1.metaStore)([
|
|
205
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
206
|
+
description: "An asset in the system",
|
|
207
|
+
namedType: "Asset",
|
|
208
|
+
}),
|
|
209
|
+
]));
|
package/cjs/Auth.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ApiKey } from "./ApiKey";
|
|
2
|
+
import type { Role } from "./Roles";
|
|
3
|
+
import type { User } from "./User";
|
|
4
|
+
export interface UserToken {
|
|
5
|
+
/**
|
|
6
|
+
* Always set to https://securetoken.google.com/GOOGLE_CLOUD_PROJECT
|
|
7
|
+
*/
|
|
8
|
+
iss: string;
|
|
9
|
+
/**
|
|
10
|
+
* Always set to GOOGLE_CLOUD_PROJECT
|
|
11
|
+
*/
|
|
12
|
+
aud: string;
|
|
13
|
+
/**
|
|
14
|
+
* The user's unique ID
|
|
15
|
+
*/
|
|
16
|
+
sub: string;
|
|
17
|
+
/**
|
|
18
|
+
* The token issue time, in seconds since epoch
|
|
19
|
+
*/
|
|
20
|
+
iat: number;
|
|
21
|
+
/**
|
|
22
|
+
* The token expiry time, normally 'iat' + 3600
|
|
23
|
+
*/
|
|
24
|
+
exp: number;
|
|
25
|
+
/**
|
|
26
|
+
* The user's unique ID. Must be equal to 'sub'
|
|
27
|
+
*/
|
|
28
|
+
user_id: string;
|
|
29
|
+
/**
|
|
30
|
+
* The time the user authenticated, normally 'iat'
|
|
31
|
+
*/
|
|
32
|
+
auth_time: number;
|
|
33
|
+
/**
|
|
34
|
+
* The sign in provider, only set when the provider is 'anonymous'
|
|
35
|
+
*/
|
|
36
|
+
provider_id?: "anonymous";
|
|
37
|
+
/**
|
|
38
|
+
* The user's primary email
|
|
39
|
+
*/
|
|
40
|
+
email?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The user's email verification status
|
|
43
|
+
*/
|
|
44
|
+
email_verified?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The user's primary phone number
|
|
47
|
+
*/
|
|
48
|
+
phone_number?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The user's display name
|
|
51
|
+
*/
|
|
52
|
+
name?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The user's profile photo URL
|
|
55
|
+
*/
|
|
56
|
+
picture?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Information on all identities linked to this user
|
|
59
|
+
*/
|
|
60
|
+
firebase: any;
|
|
61
|
+
/**
|
|
62
|
+
* Custom claims set by the developer
|
|
63
|
+
*/
|
|
64
|
+
[claim: string]: unknown;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated use `sub` instead
|
|
67
|
+
*/
|
|
68
|
+
uid?: never;
|
|
69
|
+
}
|
|
70
|
+
export interface BaseAuth {
|
|
71
|
+
type: "apiKey" | "user";
|
|
72
|
+
roles: Role[];
|
|
73
|
+
}
|
|
74
|
+
export interface ApiKeyAuth extends BaseAuth {
|
|
75
|
+
type: "apiKey";
|
|
76
|
+
apiKey: ApiKey;
|
|
77
|
+
userId: string | undefined;
|
|
78
|
+
originalUserId: string | undefined;
|
|
79
|
+
getUser: () => Promise<User | undefined>;
|
|
80
|
+
getOriginalUser: () => Promise<User | undefined>;
|
|
81
|
+
}
|
|
82
|
+
export interface UserAuth extends BaseAuth {
|
|
83
|
+
type: "user";
|
|
84
|
+
token: Token;
|
|
85
|
+
idTokenExpiresAt: number;
|
|
86
|
+
provider: string;
|
|
87
|
+
userId: string;
|
|
88
|
+
originalUserId: string;
|
|
89
|
+
getUser: () => Promise<User>;
|
|
90
|
+
getOriginalUser: () => Promise<User>;
|
|
91
|
+
}
|
|
92
|
+
export type Auth = ApiKeyAuth | UserAuth;
|
|
93
|
+
export interface Token extends UserToken {
|
|
94
|
+
roles: Role[];
|
|
95
|
+
}
|
package/cjs/Auth.js
ADDED
package/cjs/CalmLensClient.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Asset } from "./Asset";
|
|
2
|
+
import type { GetAssetChildrenQuery, GetAssetChildrenResponse, GetAssetResponse, GetAssetsPageQuery, GetAssetsPageResponse } from "./PublicApiSchemas";
|
|
2
3
|
import type { SubmitAssetOptions } from "./SharedTypes";
|
|
3
4
|
import type { CalmLensClientOptions } from "./CalmLensTypes";
|
|
4
5
|
export default class CalmLensClient {
|
|
@@ -27,15 +28,31 @@ export default class CalmLensClient {
|
|
|
27
28
|
*/
|
|
28
29
|
static verifyWebhookSignature(payload: string | object, signatureHex: string, secret: string): Promise<boolean>;
|
|
29
30
|
constructor(options: CalmLensClientOptions);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
get assets(): {
|
|
32
|
+
/**
|
|
33
|
+
* List all assets for a project
|
|
34
|
+
* @param options - Pagination and filtering options
|
|
35
|
+
* @returns Promise with paginated assets
|
|
36
|
+
*/
|
|
37
|
+
list: (options: GetAssetsPageQuery) => Promise<GetAssetsPageResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve a specific asset by ID
|
|
40
|
+
* @param assetId - The asset ID
|
|
41
|
+
* @returns Promise with asset data
|
|
42
|
+
*/
|
|
43
|
+
retrieve: (assetId: string) => Promise<GetAssetResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Get child assets of a parent asset
|
|
46
|
+
* @param assetId - The parent asset ID
|
|
47
|
+
* @param options - Pagination options
|
|
48
|
+
* @returns Promise with paginated child assets
|
|
49
|
+
*/
|
|
50
|
+
listChildren: (assetId: string, options: GetAssetChildrenQuery) => Promise<GetAssetChildrenResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Submit a new asset for processing
|
|
53
|
+
* @param options - Asset submission options
|
|
54
|
+
* @returns Promise with created asset
|
|
55
|
+
*/
|
|
56
|
+
create: (options: SubmitAssetOptions) => Promise<Asset>;
|
|
57
|
+
};
|
|
41
58
|
}
|
package/cjs/CalmLensClient.js
CHANGED
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var api_def_1 = require("api-def");
|
|
40
|
+
var SharedConstants_1 = require("shared/SharedConstants");
|
|
40
41
|
var CalmLensUtils_1 = require("./CalmLensUtils");
|
|
41
42
|
var createApi = function (options) {
|
|
42
43
|
var api = new api_def_1.Api({
|
|
@@ -51,40 +52,56 @@ var createApi = function (options) {
|
|
|
51
52
|
},
|
|
52
53
|
},
|
|
53
54
|
],
|
|
55
|
+
requestBackend: options.requestBackend,
|
|
54
56
|
});
|
|
55
57
|
return api;
|
|
56
58
|
};
|
|
57
|
-
// API endpoint definitions
|
|
59
|
+
// API endpoint definitions using schemas like CalmLensApi.ts
|
|
58
60
|
var createEndpoints = function (api) {
|
|
59
|
-
var
|
|
61
|
+
var getAssetsPage = api
|
|
60
62
|
.endpoint()
|
|
61
|
-
.
|
|
63
|
+
.queryOf()
|
|
62
64
|
.paramsOf()
|
|
63
65
|
.responseOf()
|
|
64
66
|
.build({
|
|
65
|
-
id: "
|
|
66
|
-
method: "
|
|
67
|
-
path: "/projects/:projectId/assets",
|
|
67
|
+
id: "getAssetsPage",
|
|
68
|
+
method: "get",
|
|
69
|
+
path: "/projects/:projectId/assets/page",
|
|
68
70
|
});
|
|
69
|
-
var getAsset = api
|
|
71
|
+
var getAsset = api
|
|
72
|
+
.endpoint()
|
|
73
|
+
.paramsOf()
|
|
74
|
+
.responseOf()
|
|
75
|
+
.build({
|
|
70
76
|
id: "getAsset",
|
|
71
77
|
method: "get",
|
|
72
78
|
path: "/projects/:projectId/assets/:assetId",
|
|
73
79
|
});
|
|
74
|
-
var
|
|
80
|
+
var getAssetChildren = api
|
|
75
81
|
.endpoint()
|
|
76
|
-
.queryOf()
|
|
77
82
|
.paramsOf()
|
|
83
|
+
.queryOf()
|
|
78
84
|
.responseOf()
|
|
79
85
|
.build({
|
|
80
|
-
id: "
|
|
86
|
+
id: "getAssetChildren",
|
|
81
87
|
method: "get",
|
|
82
|
-
path: "/projects/:projectId/assets/
|
|
88
|
+
path: "/projects/:projectId/assets/:assetId/children",
|
|
89
|
+
});
|
|
90
|
+
var postUploadAsset = api
|
|
91
|
+
.endpoint()
|
|
92
|
+
.bodyOf()
|
|
93
|
+
.paramsOf()
|
|
94
|
+
.responseOf()
|
|
95
|
+
.build({
|
|
96
|
+
id: "postUploadAsset",
|
|
97
|
+
method: "post",
|
|
98
|
+
path: "/projects/:projectId/assets",
|
|
83
99
|
});
|
|
84
100
|
return {
|
|
85
|
-
postUploadAsset: postUploadAsset,
|
|
86
|
-
getAsset: getAsset,
|
|
87
101
|
getAssetsPage: getAssetsPage,
|
|
102
|
+
getAsset: getAsset,
|
|
103
|
+
getAssetChildren: getAssetChildren,
|
|
104
|
+
postUploadAsset: postUploadAsset,
|
|
88
105
|
};
|
|
89
106
|
};
|
|
90
107
|
var CalmLensClient = /** @class */ (function () {
|
|
@@ -97,7 +114,7 @@ var CalmLensClient = /** @class */ (function () {
|
|
|
97
114
|
if (!options.projectId) {
|
|
98
115
|
throw new Error("Project ID is required");
|
|
99
116
|
}
|
|
100
|
-
this.options.baseUrl = (_a = this.options.baseUrl) !== null && _a !== void 0 ? _a : "https://api.
|
|
117
|
+
this.options.baseUrl = (_a = this.options.baseUrl) !== null && _a !== void 0 ? _a : "https://api.".concat(SharedConstants_1.DOMAIN, "/v1");
|
|
101
118
|
this.api = createApi(this.options);
|
|
102
119
|
this.endpoints = createEndpoints(this.api);
|
|
103
120
|
}
|
|
@@ -128,72 +145,116 @@ var CalmLensClient = /** @class */ (function () {
|
|
|
128
145
|
});
|
|
129
146
|
});
|
|
130
147
|
};
|
|
131
|
-
CalmLensClient.prototype
|
|
132
|
-
|
|
133
|
-
var
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
Object.defineProperty(CalmLensClient.prototype, "assets", {
|
|
149
|
+
get: function () {
|
|
150
|
+
var _this = this;
|
|
151
|
+
return {
|
|
152
|
+
/**
|
|
153
|
+
* List all assets for a project
|
|
154
|
+
* @param options - Pagination and filtering options
|
|
155
|
+
* @returns Promise with paginated assets
|
|
156
|
+
*/
|
|
157
|
+
list: function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
158
|
+
var result;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0: return [4 /*yield*/, this.endpoints.getAssetsPage.submit({
|
|
162
|
+
params: {
|
|
163
|
+
projectId: this.options.projectId,
|
|
164
|
+
},
|
|
165
|
+
query: options,
|
|
166
|
+
})];
|
|
167
|
+
case 1:
|
|
168
|
+
result = _a.sent();
|
|
169
|
+
return [2 /*return*/, result.data];
|
|
139
170
|
}
|
|
140
|
-
|
|
141
|
-
|
|
171
|
+
});
|
|
172
|
+
}); },
|
|
173
|
+
/**
|
|
174
|
+
* Retrieve a specific asset by ID
|
|
175
|
+
* @param assetId - The asset ID
|
|
176
|
+
* @returns Promise with asset data
|
|
177
|
+
*/
|
|
178
|
+
retrieve: function (assetId) { return __awaiter(_this, void 0, void 0, function () {
|
|
179
|
+
var result;
|
|
180
|
+
return __generator(this, function (_a) {
|
|
181
|
+
switch (_a.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
if (!assetId) {
|
|
184
|
+
throw new Error("Asset ID is required");
|
|
185
|
+
}
|
|
186
|
+
return [4 /*yield*/, this.endpoints.getAsset.submit({
|
|
187
|
+
params: {
|
|
188
|
+
projectId: this.options.projectId,
|
|
189
|
+
assetId: assetId,
|
|
190
|
+
},
|
|
191
|
+
})];
|
|
192
|
+
case 1:
|
|
193
|
+
result = _a.sent();
|
|
194
|
+
return [2 /*return*/, result.data];
|
|
142
195
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
196
|
+
});
|
|
197
|
+
}); },
|
|
198
|
+
/**
|
|
199
|
+
* Get child assets of a parent asset
|
|
200
|
+
* @param assetId - The parent asset ID
|
|
201
|
+
* @param options - Pagination options
|
|
202
|
+
* @returns Promise with paginated child assets
|
|
203
|
+
*/
|
|
204
|
+
listChildren: function (assetId, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
+
var result;
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0:
|
|
209
|
+
if (!assetId) {
|
|
210
|
+
throw new Error("Asset ID is required");
|
|
211
|
+
}
|
|
212
|
+
return [4 /*yield*/, this.endpoints.getAssetChildren.submit({
|
|
213
|
+
params: {
|
|
214
|
+
projectId: this.options.projectId,
|
|
215
|
+
assetId: assetId,
|
|
216
|
+
},
|
|
217
|
+
query: options,
|
|
218
|
+
})];
|
|
219
|
+
case 1:
|
|
220
|
+
result = _a.sent();
|
|
221
|
+
return [2 /*return*/, result.data];
|
|
164
222
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
223
|
+
});
|
|
224
|
+
}); },
|
|
225
|
+
/**
|
|
226
|
+
* Submit a new asset for processing
|
|
227
|
+
* @param options - Asset submission options
|
|
228
|
+
* @returns Promise with created asset
|
|
229
|
+
*/
|
|
230
|
+
create: function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
231
|
+
var result;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
if (!("file" in options) && !("url" in options)) {
|
|
236
|
+
throw new Error("Either file content or URL is required");
|
|
237
|
+
}
|
|
238
|
+
if (!options.name) {
|
|
239
|
+
throw new Error("Asset name is required");
|
|
240
|
+
}
|
|
241
|
+
return [4 /*yield*/, this.endpoints.postUploadAsset.submit({
|
|
242
|
+
body: options,
|
|
243
|
+
params: {
|
|
244
|
+
projectId: this.options.projectId,
|
|
245
|
+
},
|
|
246
|
+
})];
|
|
247
|
+
case 1:
|
|
248
|
+
result = _a.sent();
|
|
249
|
+
return [2 /*return*/, result.data];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}); },
|
|
253
|
+
};
|
|
254
|
+
},
|
|
255
|
+
enumerable: false,
|
|
256
|
+
configurable: true
|
|
257
|
+
});
|
|
197
258
|
return CalmLensClient;
|
|
198
259
|
}());
|
|
199
260
|
exports.default = CalmLensClient;
|