@calmlens/js-sdk 0.0.1 → 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.
Files changed (68) hide show
  1. package/cjs/ApiKey.d.ts +31 -0
  2. package/cjs/ApiKey.js +59 -0
  3. package/cjs/Asset.d.ts +83 -3
  4. package/cjs/Asset.js +198 -28
  5. package/cjs/Auth.d.ts +95 -0
  6. package/cjs/Auth.js +2 -0
  7. package/cjs/CalmLensClient.d.ts +28 -11
  8. package/cjs/CalmLensClient.js +138 -77
  9. package/cjs/CalmLensTypes.d.ts +2 -0
  10. package/cjs/Classification.js +40 -7
  11. package/cjs/DocMetaTypes.d.ts +7 -0
  12. package/cjs/DocMetaTypes.js +7 -0
  13. package/cjs/Page.d.ts +42 -0
  14. package/cjs/Page.js +94 -0
  15. package/cjs/PublicApiSchemas.d.ts +1593 -0
  16. package/cjs/PublicApiSchemas.js +334 -0
  17. package/cjs/RequestInfo.d.ts +23 -0
  18. package/cjs/RequestInfo.js +2 -0
  19. package/cjs/Roles.d.ts +21 -0
  20. package/cjs/Roles.js +84 -0
  21. package/cjs/SharedConstants.d.ts +134 -0
  22. package/cjs/SharedConstants.js +125 -0
  23. package/cjs/SharedTypes.d.ts +6 -1
  24. package/cjs/User.d.ts +17 -0
  25. package/cjs/User.js +51 -0
  26. package/cjs/UtilTypes.d.ts +30 -0
  27. package/cjs/UtilTypes.js +4 -0
  28. package/cjs/Workflow.d.ts +58 -0
  29. package/cjs/Workflow.js +83 -0
  30. package/cjs/ZodUtils.d.ts +39 -0
  31. package/cjs/ZodUtils.js +328 -0
  32. package/cjs/index.js +4 -1
  33. package/esm/ApiKey.d.ts +31 -0
  34. package/esm/ApiKey.js +23 -0
  35. package/esm/Asset.d.ts +83 -3
  36. package/esm/Asset.js +148 -12
  37. package/esm/Auth.d.ts +95 -0
  38. package/esm/Auth.js +1 -0
  39. package/esm/CalmLensClient.d.ts +28 -11
  40. package/esm/CalmLensClient.js +104 -55
  41. package/esm/CalmLensTypes.d.ts +2 -0
  42. package/esm/Classification.js +1 -1
  43. package/esm/DocMetaTypes.d.ts +7 -0
  44. package/esm/DocMetaTypes.js +4 -0
  45. package/esm/Page.d.ts +42 -0
  46. package/esm/Page.js +55 -0
  47. package/esm/PublicApiSchemas.d.ts +1593 -0
  48. package/esm/PublicApiSchemas.js +298 -0
  49. package/esm/RequestInfo.d.ts +23 -0
  50. package/esm/RequestInfo.js +1 -0
  51. package/esm/Roles.d.ts +21 -0
  52. package/esm/Roles.js +45 -0
  53. package/esm/SharedConstants.d.ts +134 -0
  54. package/esm/SharedConstants.js +122 -0
  55. package/esm/SharedTypes.d.ts +6 -1
  56. package/esm/User.d.ts +17 -0
  57. package/esm/User.js +15 -0
  58. package/esm/UtilTypes.d.ts +30 -0
  59. package/esm/UtilTypes.js +1 -0
  60. package/esm/Workflow.d.ts +58 -0
  61. package/esm/Workflow.js +46 -0
  62. package/esm/ZodUtils.d.ts +39 -0
  63. package/esm/ZodUtils.js +266 -0
  64. package/package.json +10 -10
  65. package/cjs/SchemaUtils.d.ts +0 -11
  66. package/cjs/SchemaUtils.js +0 -63
  67. package/esm/SchemaUtils.d.ts +0 -11
  68. package/esm/SchemaUtils.js +0 -46
@@ -0,0 +1,334 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DELETE_ASSET_REQUEST = exports.DELETE_ASSET_RESPONSE_SCHEMA = exports.DELETE_ASSET_PARAMS_SCHEMA = exports.PATCH_ASSET_REQUEST = exports.PATCH_ASSET_RESPONSE_SCHEMA = exports.PATCH_ASSET_BODY_SCHEMA = exports.PATCH_ASSET_PARAMS_SCHEMA = exports.POST_ASSET_REQUEST = exports.POST_ASSET_RESPONSE_SCHEMA = exports.POST_ASSET_BODY_SCHEMA = exports.POST_ASSET_PARAMS_SCHEMA = exports.GET_ASSET_CHILDREN_REQUEST = exports.GET_ASSET_CHILDREN_RESPONSE_SCHEMA = exports.GET_ASSET_CHILDREN_QUERY_SCHEMA = exports.GET_ASSET_CHILDREN_PARAMS_SCHEMA = exports.GET_ASSET_REQUEST = exports.GET_ASSET_RESPONSE_SCHEMA = exports.GET_ASSET_PARAMS_SCHEMA = exports.GET_ASSETS_PAGE_REQUEST = exports.GET_ASSETS_PAGE_RESPONSE_SCHEMA = exports.GET_ASSETS_PAGE_QUERY_SCHEMA = exports.GET_ASSETS_PAGE_PARAMS_SCHEMA = exports.PUBLIC_ERROR_CODES = void 0;
37
+ var sendable_error_1 = require("sendable-error");
38
+ var zod = __importStar(require("zod/v4"));
39
+ var zod_meta_1 = require("zod-meta");
40
+ var Asset_1 = require("./Asset");
41
+ var DocMetaTypes_1 = require("./DocMetaTypes");
42
+ var Page_1 = require("./Page");
43
+ var SharedConstants_1 = require("./SharedConstants");
44
+ var ZodUtils_1 = require("./ZodUtils");
45
+ exports.PUBLIC_ERROR_CODES = {
46
+ FILE_TOO_LARGE: new sendable_error_1.ErrorCode({
47
+ id: "upload/file-too-large",
48
+ defaultMessage: "File size exceeds limit. Maximum size for images is ".concat(SharedConstants_1.MAX_IMAGE_UPLOAD_STRING, ", for other files is ").concat(SharedConstants_1.MAX_NON_IMAGE_UPLOAD_STRING, "."),
49
+ status: 400,
50
+ }),
51
+ IMAGE_EXCEEDED_MAX_DIMENSIONS: new sendable_error_1.ErrorCode({
52
+ id: "upload/image-exceeded-max-dimensions",
53
+ defaultMessage: "Image exceeds maximum dimensions. Maximum dimensions are 12,000px.",
54
+ status: 400,
55
+ }),
56
+ UPLOAD_LIMIT_EXCEEDED: new sendable_error_1.ErrorCode({
57
+ id: "upload/limit-exceeded",
58
+ defaultMessage: "Upload limit exceeded. You have used all your free uploads. Please upgrade to Plus or Pro for unlimited uploads.",
59
+ status: 403,
60
+ }),
61
+ ASSET_NOT_FOUND: new sendable_error_1.ErrorCode({
62
+ id: "asset/not-found",
63
+ defaultMessage: "Asset not found",
64
+ status: 404,
65
+ }),
66
+ PROJECT_NOT_FOUND: new sendable_error_1.ErrorCode({
67
+ id: "project/not-found",
68
+ defaultMessage: "Project not found",
69
+ status: 404,
70
+ }),
71
+ ASSET_UPDATE_FAILED: new sendable_error_1.ErrorCode({
72
+ id: "asset/update-failed",
73
+ defaultMessage: "Failed to update asset",
74
+ status: 500,
75
+ }),
76
+ };
77
+ exports.GET_ASSETS_PAGE_PARAMS_SCHEMA = zod.object({
78
+ projectId: zod
79
+ .string()
80
+ .uuid()
81
+ .meta((0, zod_meta_1.metaStore)([
82
+ (0, DocMetaTypes_1.docPropertyInfo)({
83
+ description: "UUID of the project to fetch assets from",
84
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
85
+ }),
86
+ ])),
87
+ });
88
+ exports.GET_ASSETS_PAGE_QUERY_SCHEMA = Page_1.PAGE_QUERY_SCHEMA.extend({
89
+ filter: (0, ZodUtils_1.rsqlField)().nullish(),
90
+ });
91
+ exports.GET_ASSETS_PAGE_RESPONSE_SCHEMA = (0, Page_1.createPageSchema)(Asset_1.ASSET_SCHEMA);
92
+ exports.GET_ASSETS_PAGE_REQUEST = {
93
+ name: "Get Assets Page",
94
+ id: "get-assets-page",
95
+ method: "GET",
96
+ path: "/projects/:projectId/assets/page",
97
+ description: "Get a paginated list of assets for a project",
98
+ auth: "API Key",
99
+ sdkPath: ["assets", "list"],
100
+ schemas: {
101
+ params: exports.GET_ASSETS_PAGE_PARAMS_SCHEMA,
102
+ query: exports.GET_ASSETS_PAGE_QUERY_SCHEMA,
103
+ response: exports.GET_ASSETS_PAGE_RESPONSE_SCHEMA,
104
+ },
105
+ errorCodes: [exports.PUBLIC_ERROR_CODES.PROJECT_NOT_FOUND],
106
+ };
107
+ // ------
108
+ exports.GET_ASSET_PARAMS_SCHEMA = zod.object({
109
+ projectId: zod
110
+ .string()
111
+ .uuid()
112
+ .meta((0, zod_meta_1.metaStore)([
113
+ (0, DocMetaTypes_1.docPropertyInfo)({
114
+ description: "UUID of the project containing the asset",
115
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
116
+ }),
117
+ ])),
118
+ assetId: zod
119
+ .string()
120
+ .uuid()
121
+ .meta((0, zod_meta_1.metaStore)([
122
+ (0, DocMetaTypes_1.docPropertyInfo)({
123
+ description: "UUID of the asset to fetch",
124
+ placeholder: "987fcdeb-51a2-43d7-b890-123456789abc",
125
+ }),
126
+ ])),
127
+ });
128
+ exports.GET_ASSET_RESPONSE_SCHEMA = Asset_1.ASSET_SCHEMA;
129
+ exports.GET_ASSET_REQUEST = {
130
+ name: "Get Asset",
131
+ id: "get-asset",
132
+ method: "GET",
133
+ path: "/projects/:projectId/assets/:assetId",
134
+ description: "Get a single asset by ID",
135
+ auth: "API Key",
136
+ sdkPath: ["assets", "retrieve"],
137
+ schemas: {
138
+ params: exports.GET_ASSET_PARAMS_SCHEMA,
139
+ response: exports.GET_ASSET_RESPONSE_SCHEMA,
140
+ },
141
+ errorCodes: [
142
+ exports.PUBLIC_ERROR_CODES.ASSET_NOT_FOUND,
143
+ exports.PUBLIC_ERROR_CODES.PROJECT_NOT_FOUND,
144
+ ],
145
+ };
146
+ // ------
147
+ exports.GET_ASSET_CHILDREN_PARAMS_SCHEMA = zod.object({
148
+ projectId: zod
149
+ .string()
150
+ .uuid()
151
+ .meta((0, zod_meta_1.metaStore)([
152
+ (0, DocMetaTypes_1.docPropertyInfo)({
153
+ description: "UUID of the project containing the parent asset",
154
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
155
+ }),
156
+ ])),
157
+ assetId: zod
158
+ .string()
159
+ .uuid()
160
+ .meta((0, zod_meta_1.metaStore)([
161
+ (0, DocMetaTypes_1.docPropertyInfo)({
162
+ description: "UUID of the parent asset to fetch children for",
163
+ placeholder: "987fcdeb-51a2-43d7-b890-123456789abc",
164
+ }),
165
+ ])),
166
+ });
167
+ exports.GET_ASSET_CHILDREN_QUERY_SCHEMA = Page_1.PAGE_QUERY_SCHEMA;
168
+ exports.GET_ASSET_CHILDREN_RESPONSE_SCHEMA = (0, Page_1.createPageSchema)(Asset_1.ASSET_SCHEMA);
169
+ exports.GET_ASSET_CHILDREN_REQUEST = {
170
+ name: "Get Asset Children",
171
+ id: "get-asset-children",
172
+ method: "GET",
173
+ path: "/projects/:projectId/assets/:assetId/children",
174
+ description: "Get child assets of a parent asset",
175
+ auth: "API Key",
176
+ sdkPath: ["assets", "listChildren"],
177
+ schemas: {
178
+ params: exports.GET_ASSET_CHILDREN_PARAMS_SCHEMA,
179
+ query: exports.GET_ASSET_CHILDREN_QUERY_SCHEMA,
180
+ response: exports.GET_ASSET_CHILDREN_RESPONSE_SCHEMA,
181
+ },
182
+ };
183
+ // ------
184
+ exports.POST_ASSET_PARAMS_SCHEMA = zod.object({
185
+ projectId: zod
186
+ .string()
187
+ .uuid()
188
+ .meta((0, zod_meta_1.metaStore)([
189
+ (0, DocMetaTypes_1.docPropertyInfo)({
190
+ description: "UUID of the project to upload the asset to",
191
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
192
+ }),
193
+ ])),
194
+ });
195
+ var POST_ASSET_FILE_BODY_SCHEMA = zod.object({
196
+ file: zod.string().meta((0, zod_meta_1.metaStore)([
197
+ (0, DocMetaTypes_1.docPropertyInfo)({
198
+ description: "Base64 encoded file content or data URL",
199
+ placeholder: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...",
200
+ }),
201
+ ])),
202
+ fileType: zod.string().meta((0, zod_meta_1.metaStore)([
203
+ (0, DocMetaTypes_1.docPropertyInfo)({
204
+ description: "MIME type or file extension",
205
+ placeholder: "image/jpeg",
206
+ }),
207
+ ])),
208
+ externalUrl: zod.string().url().optional(),
209
+ });
210
+ var POST_ASSET_URL_BODY_SCHEMA = zod.object({
211
+ url: zod
212
+ .string()
213
+ .url()
214
+ .meta((0, zod_meta_1.metaStore)([
215
+ (0, DocMetaTypes_1.docPropertyInfo)({
216
+ description: "URL to fetch the asset from",
217
+ placeholder: "https://example.com/image.jpg",
218
+ }),
219
+ ])),
220
+ });
221
+ var POST_ASSET_COMMON_BODY_SCHEMA = Asset_1.ASSET_SCHEMA.pick({
222
+ name: true,
223
+ }).and(Asset_1.ASSET_SCHEMA.pick({
224
+ description: true,
225
+ processingOptions: true,
226
+ visibility: true,
227
+ }).partial());
228
+ exports.POST_ASSET_BODY_SCHEMA = zod
229
+ .union([POST_ASSET_FILE_BODY_SCHEMA, POST_ASSET_URL_BODY_SCHEMA])
230
+ .and(POST_ASSET_COMMON_BODY_SCHEMA);
231
+ exports.POST_ASSET_RESPONSE_SCHEMA = Asset_1.ASSET_SCHEMA;
232
+ exports.POST_ASSET_REQUEST = {
233
+ name: "Create Asset",
234
+ id: "post-asset",
235
+ method: "POST",
236
+ path: "/projects/:projectId/assets",
237
+ description: "Upload a new asset to a project",
238
+ auth: "API Key",
239
+ sdkPath: ["assets", "create"],
240
+ schemas: {
241
+ params: exports.POST_ASSET_PARAMS_SCHEMA,
242
+ body: exports.POST_ASSET_BODY_SCHEMA,
243
+ response: exports.POST_ASSET_RESPONSE_SCHEMA,
244
+ },
245
+ errorCodes: [
246
+ exports.PUBLIC_ERROR_CODES.FILE_TOO_LARGE,
247
+ exports.PUBLIC_ERROR_CODES.UPLOAD_LIMIT_EXCEEDED,
248
+ ],
249
+ };
250
+ // ------
251
+ exports.PATCH_ASSET_PARAMS_SCHEMA = zod.object({
252
+ projectId: zod
253
+ .string()
254
+ .uuid()
255
+ .meta((0, zod_meta_1.metaStore)([
256
+ (0, DocMetaTypes_1.docPropertyInfo)({
257
+ description: "UUID of the project containing the asset",
258
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
259
+ }),
260
+ ])),
261
+ assetId: zod
262
+ .string()
263
+ .uuid()
264
+ .meta((0, zod_meta_1.metaStore)([
265
+ (0, DocMetaTypes_1.docPropertyInfo)({
266
+ description: "UUID of the asset to update",
267
+ placeholder: "987fcdeb-51a2-43d7-b890-123456789abc",
268
+ }),
269
+ ])),
270
+ });
271
+ exports.PATCH_ASSET_BODY_SCHEMA = Asset_1.ASSET_SCHEMA.pick({
272
+ name: true,
273
+ description: true,
274
+ externalId: true,
275
+ externalUrl: true,
276
+ metadata: true,
277
+ tags: true,
278
+ visibility: true,
279
+ }).partial();
280
+ exports.PATCH_ASSET_RESPONSE_SCHEMA = Asset_1.ASSET_SCHEMA;
281
+ exports.PATCH_ASSET_REQUEST = {
282
+ name: "Update Asset",
283
+ id: "patch-asset",
284
+ method: "PATCH",
285
+ path: "/projects/:projectId/assets/:assetId",
286
+ description: "Update an existing asset",
287
+ auth: "API Key",
288
+ sdkPath: ["assets", "update"],
289
+ schemas: {
290
+ params: exports.PATCH_ASSET_PARAMS_SCHEMA,
291
+ body: exports.PATCH_ASSET_BODY_SCHEMA,
292
+ response: exports.PATCH_ASSET_RESPONSE_SCHEMA,
293
+ },
294
+ errorCodes: [
295
+ exports.PUBLIC_ERROR_CODES.ASSET_NOT_FOUND,
296
+ exports.PUBLIC_ERROR_CODES.ASSET_UPDATE_FAILED,
297
+ ],
298
+ };
299
+ // ------
300
+ exports.DELETE_ASSET_PARAMS_SCHEMA = zod.object({
301
+ projectId: zod
302
+ .string()
303
+ .uuid()
304
+ .meta((0, zod_meta_1.metaStore)([
305
+ (0, DocMetaTypes_1.docPropertyInfo)({
306
+ description: "UUID of the project containing the asset",
307
+ placeholder: "123e4567-e89b-12d3-a456-426614174000",
308
+ }),
309
+ ])),
310
+ assetId: zod
311
+ .string()
312
+ .uuid()
313
+ .meta((0, zod_meta_1.metaStore)([
314
+ (0, DocMetaTypes_1.docPropertyInfo)({
315
+ description: "UUID of the asset to delete",
316
+ placeholder: "987fcdeb-51a2-43d7-b890-123456789abc",
317
+ }),
318
+ ])),
319
+ });
320
+ exports.DELETE_ASSET_RESPONSE_SCHEMA = zod.object({});
321
+ exports.DELETE_ASSET_REQUEST = {
322
+ name: "Delete Asset",
323
+ id: "delete-asset",
324
+ method: "DELETE",
325
+ path: "/projects/:projectId/assets/:assetId",
326
+ description: "Delete an asset from a project",
327
+ auth: "API Key",
328
+ sdkPath: ["assets", "delete"],
329
+ schemas: {
330
+ params: exports.DELETE_ASSET_PARAMS_SCHEMA,
331
+ response: exports.DELETE_ASSET_RESPONSE_SCHEMA,
332
+ },
333
+ errorCodes: [exports.PUBLIC_ERROR_CODES.ASSET_NOT_FOUND],
334
+ };
@@ -0,0 +1,23 @@
1
+ import type * as zod from "zod/v4";
2
+ export interface RequestErrorCode {
3
+ getId(): string;
4
+ getDefaultMessage(): string | undefined;
5
+ is(error: any): error is any;
6
+ getStatus(): number | undefined;
7
+ }
8
+ export interface RequestInfo {
9
+ id: string;
10
+ method: string;
11
+ name: string;
12
+ path: string;
13
+ description: string;
14
+ auth: string;
15
+ sdkPath: string[];
16
+ schemas: {
17
+ params?: zod.ZodSchema;
18
+ query?: zod.ZodSchema;
19
+ body?: zod.ZodSchema;
20
+ response: zod.ZodSchema;
21
+ };
22
+ errorCodes?: RequestErrorCode[];
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/Roles.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import * as zod from "zod/v4";
2
+ import type { Auth } from "./Auth";
3
+ export declare const ROLE_SCHEMA: zod.ZodEnum<{
4
+ "system:super-admin": "system:super-admin";
5
+ "system:banned": "system:banned";
6
+ "assets:view-all": "assets:view-all";
7
+ }>;
8
+ export type Role = zod.infer<typeof ROLE_SCHEMA>;
9
+ export interface RoleInfo {
10
+ id: Role;
11
+ label: string;
12
+ description: string;
13
+ category: string;
14
+ system: boolean;
15
+ dangerous?: boolean;
16
+ color?: string;
17
+ }
18
+ export declare const ROLE_INFO: Record<Role, RoleInfo>;
19
+ export declare const getRoleInfo: (roleId: Role) => RoleInfo;
20
+ export declare const getRolesByCategory: (category: RoleInfo["category"]) => RoleInfo[];
21
+ export declare const hasRole: (auth: Auth | undefined, roles: Role | Role[]) => boolean;
package/cjs/Roles.js ADDED
@@ -0,0 +1,84 @@
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
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.hasRole = exports.getRolesByCategory = exports.getRoleInfo = exports.ROLE_INFO = exports.ROLE_SCHEMA = void 0;
37
+ var zod = __importStar(require("zod/v4"));
38
+ exports.ROLE_SCHEMA = zod.enum(["system:super-admin", "system:banned", "assets:view-all"]);
39
+ exports.ROLE_INFO = {
40
+ "system:super-admin": {
41
+ id: "system:super-admin",
42
+ system: true,
43
+ label: "Super Admin",
44
+ description: "Full administrative access to the platform",
45
+ category: "system",
46
+ dangerous: true,
47
+ color: "#ef4444",
48
+ },
49
+ "system:banned": {
50
+ id: "system:banned",
51
+ system: true,
52
+ label: "Banned",
53
+ description: "User is banned from using the platform",
54
+ category: "system",
55
+ dangerous: true,
56
+ color: "#dc2626",
57
+ },
58
+ "assets:view-all": {
59
+ id: "assets:view-all",
60
+ system: true,
61
+ label: "View All Assets",
62
+ description: "View all assets in the platform",
63
+ category: "assets",
64
+ dangerous: false,
65
+ color: "#000000",
66
+ },
67
+ };
68
+ var getRoleInfo = function (roleId) {
69
+ return exports.ROLE_INFO[roleId];
70
+ };
71
+ exports.getRoleInfo = getRoleInfo;
72
+ var getRolesByCategory = function (category) {
73
+ return Object.values(exports.ROLE_INFO).filter(function (role) { return role.category === category; });
74
+ };
75
+ exports.getRolesByCategory = getRolesByCategory;
76
+ var hasRole = function (auth, roles) {
77
+ if (!auth)
78
+ return false;
79
+ if (!auth.roles)
80
+ return false;
81
+ var roleArray = Array.isArray(roles) ? roles : [roles];
82
+ return roleArray.some(function (role) { return auth.roles.includes(role); });
83
+ };
84
+ exports.hasRole = hasRole;
@@ -0,0 +1,134 @@
1
+ import type { Fit } from "./UtilTypes";
2
+ export type CookieType = "functional" | "analytics" | "marketing" | "essential";
3
+ export interface CookieInfo {
4
+ name: string;
5
+ description: string;
6
+ expirationDescription: string;
7
+ expirationMs?: number;
8
+ type: CookieType;
9
+ providerName?: string;
10
+ }
11
+ export declare const FIRST_PARTY_COOKIES: {
12
+ readonly ACCEPTED_COOKIES_VERSION: {
13
+ readonly name: "CL_acceptedCookiesVersion";
14
+ readonly description: "Indicates the version of the cookies the user has accepted";
15
+ readonly expirationDescription: "1 year";
16
+ readonly type: "essential";
17
+ readonly providerName: "CalmLens";
18
+ };
19
+ readonly RANDOM_SEED: {
20
+ readonly name: "CL_randomnessSeed";
21
+ readonly description: "Random seed used for consistent randomization across sessions";
22
+ readonly expirationDescription: "Session";
23
+ readonly type: "functional";
24
+ readonly providerName: "CalmLens";
25
+ };
26
+ readonly EVER_LOGGED_IN: {
27
+ readonly name: "CL_everLoggedIn";
28
+ readonly description: "Indicates if the user has ever logged in to the app";
29
+ readonly expirationDescription: "10 years";
30
+ readonly type: "essential";
31
+ readonly providerName: "CalmLens";
32
+ };
33
+ readonly ID_TOKEN_EXPIRES_AT: {
34
+ readonly name: "CL_idTokenExpiresAt";
35
+ readonly description: "User authentication token expiration time";
36
+ readonly expirationDescription: "Session";
37
+ readonly type: "essential";
38
+ readonly providerName: "CalmLens";
39
+ };
40
+ readonly ID_TOKEN: {
41
+ readonly name: "CL_idToken";
42
+ readonly description: "User authentication token";
43
+ readonly expirationDescription: "Session";
44
+ readonly type: "essential";
45
+ readonly providerName: "CalmLens";
46
+ };
47
+ readonly LOGGED_IN: {
48
+ readonly name: "CL_loggedIn";
49
+ readonly description: "Indicates if the user is currently logged in";
50
+ readonly expirationDescription: "Session";
51
+ readonly type: "essential";
52
+ readonly providerName: "CalmLens";
53
+ };
54
+ readonly REFRESH_TOKEN: {
55
+ readonly name: "CL_refreshToken";
56
+ readonly description: "User refresh token";
57
+ readonly expirationDescription: "Session";
58
+ readonly type: "essential";
59
+ readonly providerName: "CalmLens";
60
+ };
61
+ readonly PRE_RENDERED_WIDTH: {
62
+ readonly name: "CL_preRenderedWidth";
63
+ readonly description: "Indicates the viewport width of the user";
64
+ readonly expirationDescription: "Session";
65
+ readonly type: "essential";
66
+ readonly providerName: "CalmLens";
67
+ };
68
+ readonly SELECTED_PROJECT_ID: {
69
+ readonly name: "CL_selectedProjectId";
70
+ readonly description: "The currently selected project ID";
71
+ readonly expirationDescription: "1 year";
72
+ readonly type: "functional";
73
+ readonly providerName: "CalmLens";
74
+ };
75
+ readonly ASSET_DASHBOARD_STATE: {
76
+ readonly name: "CL_assetDashboardState";
77
+ readonly description: "Asset dashboard persistent state (view mode, filters, etc.)";
78
+ readonly expirationDescription: "1 year";
79
+ readonly expirationMs: number;
80
+ readonly type: "functional";
81
+ readonly providerName: "CalmLens";
82
+ };
83
+ readonly ASSET_VIEW: {
84
+ readonly name: "CL_assetView";
85
+ readonly description: "Preferred view mode for an asset's sub-assets (append _<assetId> to the name)";
86
+ readonly expirationDescription: "1 year";
87
+ readonly expirationMs: number;
88
+ readonly type: "functional";
89
+ readonly providerName: "CalmLens";
90
+ };
91
+ readonly PORTAL_SIDEBAR_SPLIT_PANE: {
92
+ readonly name: "CL_portalSidebarSplitPane";
93
+ readonly description: "Portal sidebar split pane panel sizes";
94
+ readonly expirationDescription: "1 year";
95
+ readonly expirationMs: number;
96
+ readonly type: "functional";
97
+ readonly providerName: "CalmLens";
98
+ };
99
+ readonly PORTAL_LAYOUT_SPLIT_PANE: {
100
+ readonly name: "CL_portalLayoutSplitPane";
101
+ readonly description: "Portal layout horizontal split pane panel sizes";
102
+ readonly expirationDescription: "1 year";
103
+ readonly expirationMs: number;
104
+ readonly type: "functional";
105
+ readonly providerName: "CalmLens";
106
+ };
107
+ };
108
+ export declare const THIRD_PARTY_COOKIES: {
109
+ readonly STRIPE: {
110
+ readonly name: "__stripe_mid";
111
+ readonly description: "Payment processing";
112
+ readonly expirationDescription: "Session";
113
+ readonly type: "essential";
114
+ readonly providerName: "Stripe";
115
+ };
116
+ };
117
+ export declare const PAYMENT_RETURN_TYPES: readonly ["edit", "account", "settings", "subscription"];
118
+ export type PaymentReturnType = (typeof PAYMENT_RETURN_TYPES)[number];
119
+ export declare const PLAN_TYPES: readonly ["plus", "pro"];
120
+ export type PlanType = (typeof PLAN_TYPES)[number];
121
+ export declare const IS_BACKEND: boolean;
122
+ export declare const COOKIE_NEVER_EXPIRES: number;
123
+ export declare const DEFAULT_FIT: Fit;
124
+ export declare const MAX_IMAGE_UPLOAD_MB = 10;
125
+ export declare const MAX_IMAGE_UPLOAD_STRING = "10MB";
126
+ export declare const MAX_IMAGE_DIMENSION = 12000;
127
+ export declare const MAX_IMAGE_UPLOAD_BYTES: number;
128
+ export declare const MAX_NON_IMAGE_UPLOAD_MB = 5000;
129
+ export declare const MAX_NON_IMAGE_UPLOAD_BYTES: number;
130
+ export declare const MAX_NON_IMAGE_UPLOAD_STRING = "5GB";
131
+ export declare const IMPERSONATION_COOKIE_NAME = "CL_impersonation";
132
+ export declare const DOMAIN = "calmlens.com";
133
+ export declare const TITLE = "CalmLens";
134
+ export declare const BLURB = "AI-powered content moderation for safer online communities";