@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/ZodUtils.js
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
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.zodSchemaToTypeScript = exports.rsqlField = exports.urlField = exports.saneStringField = exports.updatedAtField = exports.createdAtField = exports.uuidField = exports.primaryUuidField = exports.nonNullable = exports.isZodTypeExtends = exports.getSchemaDisplayInfo = exports.getZodTypeChain = exports.isZodRequired = void 0;
|
|
37
|
+
var zod = __importStar(require("zod/v4"));
|
|
38
|
+
var zod_meta_1 = require("zod-meta");
|
|
39
|
+
var zodbase_1 = require("zodbase");
|
|
40
|
+
var DocMetaTypes_1 = require("./DocMetaTypes");
|
|
41
|
+
var ValidationUtils_1 = require("./ValidationUtils");
|
|
42
|
+
var isZodRequired = function (type) {
|
|
43
|
+
return !(0, exports.isZodTypeExtends)(type, zod.ZodOptional);
|
|
44
|
+
};
|
|
45
|
+
exports.isZodRequired = isZodRequired;
|
|
46
|
+
var getZodTypeChain = function (type) {
|
|
47
|
+
var _a;
|
|
48
|
+
var chain = [];
|
|
49
|
+
var current = type;
|
|
50
|
+
while (current === null || current === void 0 ? void 0 : current.def) {
|
|
51
|
+
chain.push(current);
|
|
52
|
+
var innerType = (_a = current.def.innerType) !== null && _a !== void 0 ? _a : current.def.in;
|
|
53
|
+
current = innerType === current ? null : innerType;
|
|
54
|
+
}
|
|
55
|
+
return chain;
|
|
56
|
+
};
|
|
57
|
+
exports.getZodTypeChain = getZodTypeChain;
|
|
58
|
+
var getSchemaDisplayInfo = function (type) {
|
|
59
|
+
var chain = (0, exports.getZodTypeChain)(type);
|
|
60
|
+
var metaItem = (0, zod_meta_1.getMetaItem)(type, DocMetaTypes_1.docPropertyInfo);
|
|
61
|
+
var description = (metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.description) || type.description;
|
|
62
|
+
var defaultValue = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.defaultValue;
|
|
63
|
+
var placeholder = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.placeholder;
|
|
64
|
+
var namedType = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.namedType;
|
|
65
|
+
var mainType = type;
|
|
66
|
+
var qualifierTypes = new Set();
|
|
67
|
+
var enumValues;
|
|
68
|
+
for (var _i = 0, chain_1 = chain; _i < chain_1.length; _i++) {
|
|
69
|
+
var item = chain_1[_i];
|
|
70
|
+
if (item.def.innerType) {
|
|
71
|
+
if (item.def.type === "nullable" || item.def.type === "optional") {
|
|
72
|
+
qualifierTypes.add("optional");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
mainType = item;
|
|
77
|
+
}
|
|
78
|
+
// Check for enum values
|
|
79
|
+
if (item.def.type === "enum") {
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
enumValues = Object.values(item.def.entries);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var typeDisplay = mainType.def.type;
|
|
85
|
+
// If it's an enum, show the enum values
|
|
86
|
+
if (enumValues && enumValues.length > 0) {
|
|
87
|
+
typeDisplay = "enum";
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
mainType: mainType.def.type,
|
|
91
|
+
description: description,
|
|
92
|
+
defaultValue: defaultValue,
|
|
93
|
+
placeholder: placeholder,
|
|
94
|
+
optional: !(0, exports.isZodRequired)(type),
|
|
95
|
+
enumValues: enumValues,
|
|
96
|
+
namedType: namedType,
|
|
97
|
+
type: "".concat(typeDisplay).concat(qualifierTypes.size > 0 ? " (".concat(Array.from(qualifierTypes).join(", "), ")") : ""),
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
exports.getSchemaDisplayInfo = getSchemaDisplayInfo;
|
|
101
|
+
var isZodTypeExtends = function (type, zodType) {
|
|
102
|
+
if (type instanceof zodType) {
|
|
103
|
+
return type;
|
|
104
|
+
}
|
|
105
|
+
// @ts-expect-error
|
|
106
|
+
if (type.def.type === "union") {
|
|
107
|
+
// @ts-expect-error
|
|
108
|
+
for (var _i = 0, _a = type.def.options; _i < _a.length; _i++) {
|
|
109
|
+
var option = _a[_i];
|
|
110
|
+
if ((0, exports.isZodTypeExtends)(option, zodType)) {
|
|
111
|
+
return option;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
// @ts-expect-error
|
|
117
|
+
var rootType = type.def.innerType;
|
|
118
|
+
if (rootType) {
|
|
119
|
+
return (0, exports.isZodTypeExtends)(rootType, zodType);
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
};
|
|
123
|
+
exports.isZodTypeExtends = isZodTypeExtends;
|
|
124
|
+
var nonNullable = function (schema) {
|
|
125
|
+
return schema.refine(function (data) {
|
|
126
|
+
if (data === null || data === undefined) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
for (var key in data) {
|
|
130
|
+
if (data[key] === null || data[key] === undefined) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}, {
|
|
136
|
+
message: "Value cannot contain null or undefined",
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
exports.nonNullable = nonNullable;
|
|
140
|
+
var primaryUuidField = function () {
|
|
141
|
+
return zod
|
|
142
|
+
.string()
|
|
143
|
+
.uuid({
|
|
144
|
+
version: "v4",
|
|
145
|
+
})
|
|
146
|
+
.meta((0, zodbase_1.metaStore)([(0, zodbase_1.primaryKey)()]));
|
|
147
|
+
};
|
|
148
|
+
exports.primaryUuidField = primaryUuidField;
|
|
149
|
+
var uuidField = function () {
|
|
150
|
+
return zod.string().uuid({
|
|
151
|
+
version: "v4",
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
exports.uuidField = uuidField;
|
|
155
|
+
var createdAtField = function () { return zod.number().int(); };
|
|
156
|
+
exports.createdAtField = createdAtField;
|
|
157
|
+
var updatedAtField = function () {
|
|
158
|
+
return zod
|
|
159
|
+
.number()
|
|
160
|
+
.int()
|
|
161
|
+
.optional()
|
|
162
|
+
.meta((0, zodbase_1.metaStore)([(0, zodbase_1.updatedAt)()]));
|
|
163
|
+
};
|
|
164
|
+
exports.updatedAtField = updatedAtField;
|
|
165
|
+
var SIZE_LIMITS = {
|
|
166
|
+
small: 64,
|
|
167
|
+
medium: 200,
|
|
168
|
+
large: 1500,
|
|
169
|
+
};
|
|
170
|
+
var saneStringField = function (options) {
|
|
171
|
+
return zod
|
|
172
|
+
.string()
|
|
173
|
+
.transform(function (value) { return value.trim(); })
|
|
174
|
+
.refine(function (value) {
|
|
175
|
+
if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}, "Not long enough")
|
|
180
|
+
.refine(function (value) {
|
|
181
|
+
var _a;
|
|
182
|
+
var sizeLimit = SIZE_LIMITS[(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : "medium"];
|
|
183
|
+
return typeof value === "string" && value.length < sizeLimit;
|
|
184
|
+
}, "Too long");
|
|
185
|
+
};
|
|
186
|
+
exports.saneStringField = saneStringField;
|
|
187
|
+
var urlField = function () {
|
|
188
|
+
return (0, exports.saneStringField)().refine(function (value) {
|
|
189
|
+
/*if (encodeURI(value) !== value) {
|
|
190
|
+
return false;
|
|
191
|
+
}*/
|
|
192
|
+
var parsedUrl = (0, ValidationUtils_1.validateUrl)(value);
|
|
193
|
+
return Boolean(parsedUrl);
|
|
194
|
+
}, "Invalid link");
|
|
195
|
+
};
|
|
196
|
+
exports.urlField = urlField;
|
|
197
|
+
var rsqlField = function () {
|
|
198
|
+
return (0, exports.saneStringField)({
|
|
199
|
+
type: "large",
|
|
200
|
+
}).meta((0, zodbase_1.metaStore)([
|
|
201
|
+
(0, DocMetaTypes_1.docPropertyInfo)({
|
|
202
|
+
description: "RSQL filter string for filtering results. See [REST API Documentation](/docs/rest) for detailed syntax.\n\n**Examples:**\n- `status==rejected;parentId==null` (AND conditions)\n- `status==rejected,status==error` (OR conditions)\n- `price>100;price<500` (range filtering)\n- `tags=in=(react,typescript)` (array membership)\n\n**Supported operators:** `==`, `!=`, `>`, `>=`, `<`, `<=`, `=in=`, `=out=`, `=like=`\n\n**Logical operators:** `;` (AND), `,` (OR)",
|
|
203
|
+
placeholder: "status==approved;type==image",
|
|
204
|
+
}),
|
|
205
|
+
]));
|
|
206
|
+
};
|
|
207
|
+
exports.rsqlField = rsqlField;
|
|
208
|
+
/**
|
|
209
|
+
* Converts a Zod schema to a TypeScript type definition string
|
|
210
|
+
*/
|
|
211
|
+
var zodSchemaToTypeScript = function (schema, indent) {
|
|
212
|
+
if (indent === void 0) { indent = 0; }
|
|
213
|
+
var spaces = " ".repeat(indent);
|
|
214
|
+
var chain = (0, exports.getZodTypeChain)(schema);
|
|
215
|
+
// Check for optional/nullable
|
|
216
|
+
var isOptional = chain.some(function (s) { return s.def.type === "optional"; });
|
|
217
|
+
var isNullable = chain.some(function (s) { return s.def.type === "nullable"; });
|
|
218
|
+
// Get the core type
|
|
219
|
+
var coreSchema = schema;
|
|
220
|
+
for (var _i = 0, chain_2 = chain; _i < chain_2.length; _i++) {
|
|
221
|
+
var s = chain_2[_i];
|
|
222
|
+
if (s.def.innerType) {
|
|
223
|
+
coreSchema = s.def.innerType;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
var typeStr = "";
|
|
227
|
+
// Handle different types
|
|
228
|
+
if (coreSchema.def.type === "string") {
|
|
229
|
+
typeStr = "string";
|
|
230
|
+
}
|
|
231
|
+
else if (coreSchema.def.type === "number") {
|
|
232
|
+
typeStr = "number";
|
|
233
|
+
}
|
|
234
|
+
else if (coreSchema.def.type === "boolean") {
|
|
235
|
+
typeStr = "boolean";
|
|
236
|
+
}
|
|
237
|
+
else if (coreSchema.def.type === "bigint") {
|
|
238
|
+
typeStr = "bigint";
|
|
239
|
+
}
|
|
240
|
+
else if (coreSchema.def.type === "date") {
|
|
241
|
+
typeStr = "Date";
|
|
242
|
+
}
|
|
243
|
+
else if (coreSchema.def.type === "null") {
|
|
244
|
+
typeStr = "null";
|
|
245
|
+
}
|
|
246
|
+
else if (coreSchema.def.type === "undefined") {
|
|
247
|
+
typeStr = "undefined";
|
|
248
|
+
}
|
|
249
|
+
else if (coreSchema.def.type === "any") {
|
|
250
|
+
typeStr = "any";
|
|
251
|
+
}
|
|
252
|
+
else if (coreSchema.def.type === "unknown") {
|
|
253
|
+
typeStr = "unknown";
|
|
254
|
+
}
|
|
255
|
+
else if (coreSchema.def.type === "never") {
|
|
256
|
+
typeStr = "never";
|
|
257
|
+
}
|
|
258
|
+
else if (coreSchema.def.type === "void") {
|
|
259
|
+
typeStr = "void";
|
|
260
|
+
}
|
|
261
|
+
else if (coreSchema.def.type === "literal") {
|
|
262
|
+
var value = coreSchema.def.value;
|
|
263
|
+
typeStr = typeof value === "string" ? "\"".concat(value, "\"") : String(value);
|
|
264
|
+
}
|
|
265
|
+
else if (coreSchema.def.type === "enum") {
|
|
266
|
+
var entries = Object.values(coreSchema.def.entries);
|
|
267
|
+
typeStr = entries.map(function (e) { return "\"".concat(e, "\""); }).join(" | ");
|
|
268
|
+
}
|
|
269
|
+
else if (coreSchema.def.type === "array") {
|
|
270
|
+
var element = coreSchema.def.element;
|
|
271
|
+
var elementType = (0, exports.zodSchemaToTypeScript)(element, indent);
|
|
272
|
+
typeStr = "".concat(elementType, "[]");
|
|
273
|
+
}
|
|
274
|
+
else if (coreSchema.def.type === "object") {
|
|
275
|
+
var shape = coreSchema.def.shape || {};
|
|
276
|
+
var fields = Object.entries(shape).map(function (_a) {
|
|
277
|
+
var key = _a[0], fieldSchema = _a[1];
|
|
278
|
+
var fieldInfo = (0, exports.getSchemaDisplayInfo)(fieldSchema);
|
|
279
|
+
var fieldType = (0, exports.zodSchemaToTypeScript)(fieldSchema, indent + 1);
|
|
280
|
+
var optional = fieldInfo.optional ? "?" : "";
|
|
281
|
+
return "".concat(spaces, " ").concat(key).concat(optional, ": ").concat(fieldType, ";");
|
|
282
|
+
});
|
|
283
|
+
if (fields.length === 0) {
|
|
284
|
+
typeStr = "{}";
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
typeStr = "{\n".concat(fields.join("\n"), "\n").concat(spaces, "}");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else if (coreSchema.def.type === "union") {
|
|
291
|
+
var options = coreSchema.def.options || [];
|
|
292
|
+
var types = options.map(function (opt) { return (0, exports.zodSchemaToTypeScript)(opt, indent); });
|
|
293
|
+
typeStr = types.join(" | ");
|
|
294
|
+
}
|
|
295
|
+
else if (coreSchema.def.type === "intersection") {
|
|
296
|
+
var left = coreSchema.def.left;
|
|
297
|
+
var right = coreSchema.def.right;
|
|
298
|
+
var leftType = (0, exports.zodSchemaToTypeScript)(left, indent);
|
|
299
|
+
var rightType = (0, exports.zodSchemaToTypeScript)(right, indent);
|
|
300
|
+
typeStr = "".concat(leftType, " & ").concat(rightType);
|
|
301
|
+
}
|
|
302
|
+
else if (coreSchema.def.type === "record") {
|
|
303
|
+
var keyType = coreSchema.def.keyType
|
|
304
|
+
? (0, exports.zodSchemaToTypeScript)(coreSchema.def.keyType, indent)
|
|
305
|
+
: "string";
|
|
306
|
+
var valueType = coreSchema.def.valueType
|
|
307
|
+
? (0, exports.zodSchemaToTypeScript)(coreSchema.def.valueType, indent)
|
|
308
|
+
: "any";
|
|
309
|
+
typeStr = "Record<".concat(keyType, ", ").concat(valueType, ">");
|
|
310
|
+
}
|
|
311
|
+
else if (coreSchema.def.type === "tuple") {
|
|
312
|
+
var items = coreSchema.def.items || [];
|
|
313
|
+
var types = items.map(function (item) { return (0, exports.zodSchemaToTypeScript)(item, indent); });
|
|
314
|
+
typeStr = "[".concat(types.join(", "), "]");
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
typeStr = "unknown";
|
|
318
|
+
}
|
|
319
|
+
// Add optional/nullable modifiers
|
|
320
|
+
if (isNullable && !typeStr.includes("null")) {
|
|
321
|
+
typeStr = "".concat(typeStr, " | null");
|
|
322
|
+
}
|
|
323
|
+
if (isOptional && indent === 0) {
|
|
324
|
+
typeStr = "".concat(typeStr, " | undefined");
|
|
325
|
+
}
|
|
326
|
+
return typeStr;
|
|
327
|
+
};
|
|
328
|
+
exports.zodSchemaToTypeScript = zodSchemaToTypeScript;
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/// <reference types="typescript" />
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.verifyWebhookSignature = exports.CalmLensClient = void 0;
|
|
5
8
|
var CalmLensClient_1 = require("./CalmLensClient");
|
|
6
|
-
Object.defineProperty(exports, "CalmLensClient", { enumerable: true, get: function () { return CalmLensClient_1.default; } });
|
|
9
|
+
Object.defineProperty(exports, "CalmLensClient", { enumerable: true, get: function () { return __importDefault(CalmLensClient_1).default; } });
|
|
7
10
|
var CalmLensUtils_1 = require("./CalmLensUtils");
|
|
8
11
|
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return CalmLensUtils_1.verifyWebhookSignature; } });
|
package/esm/ApiKey.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as zod from "zod/v4";
|
|
2
|
+
export declare const API_KEY_STATUS_SCHEMA: zod.ZodEnum<{
|
|
3
|
+
active: "active";
|
|
4
|
+
revoked: "revoked";
|
|
5
|
+
expired: "expired";
|
|
6
|
+
}>;
|
|
7
|
+
export type ApiKeyStatus = zod.infer<typeof API_KEY_STATUS_SCHEMA>;
|
|
8
|
+
export declare const API_KEY_SCHEMA: zod.ZodObject<{
|
|
9
|
+
id: zod.ZodString;
|
|
10
|
+
projectId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
11
|
+
userId: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
12
|
+
createdAt: zod.ZodNumber;
|
|
13
|
+
updatedAt: zod.ZodOptional<zod.ZodNumber>;
|
|
14
|
+
name: zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
|
|
15
|
+
description: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
16
|
+
keyHash: zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
|
|
17
|
+
keyPrefix: zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
|
|
18
|
+
roles: zod.ZodOptional<zod.ZodNullable<zod.ZodArray<zod.ZodEnum<{
|
|
19
|
+
"system:super-admin": "system:super-admin";
|
|
20
|
+
"system:banned": "system:banned";
|
|
21
|
+
"assets:view-all": "assets:view-all";
|
|
22
|
+
}>>>>;
|
|
23
|
+
status: zod.ZodEnum<{
|
|
24
|
+
active: "active";
|
|
25
|
+
revoked: "revoked";
|
|
26
|
+
expired: "expired";
|
|
27
|
+
}>;
|
|
28
|
+
expiresAt: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
29
|
+
lastUsedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
30
|
+
}, zod.z.core.$strip>;
|
|
31
|
+
export type ApiKey = zod.infer<typeof API_KEY_SCHEMA>;
|
package/esm/ApiKey.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as zod from "zod/v4";
|
|
2
|
+
import { ROLE_SCHEMA } from "./Roles";
|
|
3
|
+
import { createdAtField, primaryUuidField, saneStringField, updatedAtField, uuidField, } from "./ZodUtils";
|
|
4
|
+
export const API_KEY_STATUS_SCHEMA = zod.enum(["active", "revoked", "expired"]);
|
|
5
|
+
export const API_KEY_SCHEMA = zod.object({
|
|
6
|
+
id: primaryUuidField(),
|
|
7
|
+
projectId: uuidField().nullish(),
|
|
8
|
+
userId: saneStringField().nullish(),
|
|
9
|
+
createdAt: createdAtField(),
|
|
10
|
+
updatedAt: updatedAtField(),
|
|
11
|
+
name: saneStringField({
|
|
12
|
+
type: "medium",
|
|
13
|
+
}),
|
|
14
|
+
description: saneStringField({
|
|
15
|
+
type: "large",
|
|
16
|
+
}).nullish(),
|
|
17
|
+
keyHash: saneStringField(), // Store hashed version of the key for security
|
|
18
|
+
keyPrefix: saneStringField(), // Store first few characters for identification
|
|
19
|
+
roles: zod.array(ROLE_SCHEMA).nullish(),
|
|
20
|
+
status: API_KEY_STATUS_SCHEMA,
|
|
21
|
+
expiresAt: zod.number().nullish(), // Unix timestamp
|
|
22
|
+
lastUsedAt: zod.number().nullish(), // Unix timestamp
|
|
23
|
+
});
|
package/esm/Asset.d.ts
CHANGED
|
@@ -7,18 +7,56 @@ export declare const ASSET_STATUS_SCHEMA: zod.ZodEnum<{
|
|
|
7
7
|
}>;
|
|
8
8
|
export type AssetStatus = zod.infer<typeof ASSET_STATUS_SCHEMA>;
|
|
9
9
|
export declare const ASSET_TYPE_SCHEMA: zod.ZodEnum<{
|
|
10
|
+
file: "file";
|
|
10
11
|
image: "image";
|
|
11
12
|
video: "video";
|
|
12
13
|
audio: "audio";
|
|
13
|
-
document: "document";
|
|
14
|
+
"plaintext-document": "plaintext-document";
|
|
15
|
+
"multimedia-document": "multimedia-document";
|
|
14
16
|
website: "website";
|
|
15
17
|
}>;
|
|
16
18
|
export type AssetType = zod.infer<typeof ASSET_TYPE_SCHEMA>;
|
|
19
|
+
/**
|
|
20
|
+
* MIME types that are considered multimedia documents
|
|
21
|
+
* (documents that contain both text and embedded images/media)
|
|
22
|
+
*/
|
|
23
|
+
export declare const MULTIMEDIA_DOCUMENT_MIME_TYPES: readonly ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/msword", "application/rtf", "application/vnd.oasis.opendocument.text"];
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a MIME type is a multimedia document
|
|
26
|
+
*/
|
|
27
|
+
export declare const isMultimediaDocumentMimeType: (mimeType: string) => boolean;
|
|
17
28
|
export declare const ASSET_VISIBILITY_SCHEMA: zod.ZodEnum<{
|
|
18
29
|
public: "public";
|
|
19
30
|
private: "private";
|
|
20
31
|
}>;
|
|
21
32
|
export type AssetVisibility = zod.infer<typeof ASSET_VISIBILITY_SCHEMA>;
|
|
33
|
+
export interface CheckSums {
|
|
34
|
+
readonly md5?: string;
|
|
35
|
+
readonly sha1?: string;
|
|
36
|
+
readonly sha256?: string;
|
|
37
|
+
readonly sha384?: string;
|
|
38
|
+
readonly sha512?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const CHECKSUMS_SCHEMA: zod.ZodObject<{
|
|
41
|
+
md5: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
42
|
+
sha1: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
43
|
+
sha256: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
44
|
+
sha384: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
45
|
+
sha512: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
46
|
+
}, zod.z.core.$strip>;
|
|
47
|
+
export declare const IMAGE_DATA_SCHEMA: zod.ZodObject<{
|
|
48
|
+
perceptualHash: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
49
|
+
}, zod.z.core.$strip>;
|
|
50
|
+
export type ImageData = zod.infer<typeof IMAGE_DATA_SCHEMA>;
|
|
51
|
+
export declare const DOCUMENT_DATA_SCHEMA: zod.ZodObject<{}, zod.z.core.$strip>;
|
|
52
|
+
export type DocumentData = zod.infer<typeof DOCUMENT_DATA_SCHEMA>;
|
|
53
|
+
export declare const PROCESSING_OPTIONS_SCHEMA: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
54
|
+
keepAfterProcessing: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
55
|
+
image: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
56
|
+
ocrEnabled: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
57
|
+
}, zod.z.core.$strip>>>;
|
|
58
|
+
}, zod.z.core.$strip>>>;
|
|
59
|
+
export type ProcessingOptions = zod.infer<typeof PROCESSING_OPTIONS_SCHEMA>;
|
|
22
60
|
export declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
23
61
|
id: zod.ZodString;
|
|
24
62
|
projectId: zod.ZodString;
|
|
@@ -27,6 +65,17 @@ export declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
27
65
|
parentId: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
28
66
|
createdAt: zod.ZodNumber;
|
|
29
67
|
updatedAt: zod.ZodOptional<zod.ZodNumber>;
|
|
68
|
+
checksums: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
69
|
+
md5: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
70
|
+
sha1: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
71
|
+
sha256: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
72
|
+
sha384: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
73
|
+
sha512: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
74
|
+
}, zod.z.core.$strip>>>;
|
|
75
|
+
imageData: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
76
|
+
perceptualHash: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
77
|
+
}, zod.z.core.$strip>>>;
|
|
78
|
+
documentData: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{}, zod.z.core.$strip>>>;
|
|
30
79
|
name: zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
|
|
31
80
|
fileFormat: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
32
81
|
fileExtension: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
@@ -37,10 +86,12 @@ export declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
37
86
|
storageId: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
38
87
|
averageColor: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
39
88
|
type: zod.ZodEnum<{
|
|
89
|
+
file: "file";
|
|
40
90
|
image: "image";
|
|
41
91
|
video: "video";
|
|
42
92
|
audio: "audio";
|
|
43
|
-
document: "document";
|
|
93
|
+
"plaintext-document": "plaintext-document";
|
|
94
|
+
"multimedia-document": "multimedia-document";
|
|
44
95
|
website: "website";
|
|
45
96
|
}>;
|
|
46
97
|
previewHash: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
@@ -100,10 +151,39 @@ export declare const ASSET_SCHEMA: zod.ZodObject<{
|
|
|
100
151
|
approved: "approved";
|
|
101
152
|
rejected: "rejected";
|
|
102
153
|
}>;
|
|
103
|
-
|
|
154
|
+
extractedTextId: zod.ZodOptional<zod.ZodNullable<zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>>>;
|
|
155
|
+
processingOptions: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
156
|
+
keepAfterProcessing: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
157
|
+
image: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
158
|
+
ocrEnabled: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
159
|
+
}, zod.z.core.$strip>>>;
|
|
160
|
+
}, zod.z.core.$strip>>>;
|
|
104
161
|
visibility: zod.ZodOptional<zod.ZodNullable<zod.ZodEnum<{
|
|
105
162
|
public: "public";
|
|
106
163
|
private: "private";
|
|
107
164
|
}>>>;
|
|
165
|
+
storageDeletedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodNumber>>;
|
|
166
|
+
classificationWorkflow: zod.ZodOptional<zod.ZodNullable<zod.ZodObject<{
|
|
167
|
+
id: zod.ZodString;
|
|
168
|
+
name: zod.ZodString;
|
|
169
|
+
steps: zod.ZodArray<zod.ZodObject<{
|
|
170
|
+
id: zod.ZodString;
|
|
171
|
+
label: zod.ZodString;
|
|
172
|
+
status: zod.ZodEnum<{
|
|
173
|
+
error: "error";
|
|
174
|
+
pending: "pending";
|
|
175
|
+
in_progress: "in_progress";
|
|
176
|
+
completed: "completed";
|
|
177
|
+
skipped: "skipped";
|
|
178
|
+
}>;
|
|
179
|
+
optional: zod.ZodOptional<zod.ZodBoolean>;
|
|
180
|
+
startedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
181
|
+
completedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
182
|
+
error: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
|
|
183
|
+
}, zod.z.core.$strip>>;
|
|
184
|
+
createdAt: zod.ZodString;
|
|
185
|
+
updatedAt: zod.ZodString;
|
|
186
|
+
}, zod.z.core.$strip>>>;
|
|
108
187
|
}, zod.z.core.$strip>;
|
|
109
188
|
export type Asset = zod.infer<typeof ASSET_SCHEMA>;
|
|
189
|
+
export type AssetInput = Omit<zod.input<typeof ASSET_SCHEMA>, "createdAt" | "status">;
|