@kinotic-ai/idl 1.0.0-beta.0

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/dist/index.cjs ADDED
@@ -0,0 +1,392 @@
1
+ var import_node_module = require("node:module");
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ function __accessProp(key) {
7
+ return this[key];
8
+ }
9
+ var __toCommonJS = (from) => {
10
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
+ if (entry)
12
+ return entry;
13
+ entry = __defProp({}, "__esModule", { value: true });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (var key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(entry, key))
17
+ __defProp(entry, key, {
18
+ get: __accessProp.bind(from, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ __moduleCache.set(from, entry);
23
+ return entry;
24
+ };
25
+ var __moduleCache;
26
+ var __returnValue = (v) => v;
27
+ function __exportSetter(name, newValue) {
28
+ this[name] = __returnValue.bind(null, newValue);
29
+ }
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, {
33
+ get: all[name],
34
+ enumerable: true,
35
+ configurable: true,
36
+ set: __exportSetter.bind(all, name)
37
+ });
38
+ };
39
+
40
+ // packages/idl/src/index.ts
41
+ var exports_src = {};
42
+ __export(exports_src, {
43
+ VoidC3Type: () => VoidC3Type,
44
+ UnionC3Type: () => UnionC3Type,
45
+ StringC3Type: () => StringC3Type,
46
+ ShortC3Type: () => ShortC3Type,
47
+ ServiceDefinition: () => ServiceDefinition,
48
+ ReferenceC3Type: () => ReferenceC3Type,
49
+ PropertyDefinition: () => PropertyDefinition,
50
+ ParameterDefinition: () => ParameterDefinition,
51
+ ObjectC3Type: () => ObjectC3Type,
52
+ NotNullDecorator: () => NotNullDecorator,
53
+ NamespaceDefinition: () => NamespaceDefinition,
54
+ MapC3Type: () => MapC3Type,
55
+ LongC3Type: () => LongC3Type,
56
+ IntC3Type: () => IntC3Type,
57
+ FunctionDefinition: () => FunctionDefinition,
58
+ FloatC3Type: () => FloatC3Type,
59
+ EnumC3Type: () => EnumC3Type,
60
+ DoubleC3Type: () => DoubleC3Type,
61
+ DateC3Type: () => DateC3Type,
62
+ ComplexC3Type: () => ComplexC3Type,
63
+ CharC3Type: () => CharC3Type,
64
+ C3Type: () => C3Type,
65
+ C3Decorator: () => C3Decorator,
66
+ ByteC3Type: () => ByteC3Type,
67
+ BooleanC3Type: () => BooleanC3Type,
68
+ ArrayC3Type: () => ArrayC3Type
69
+ });
70
+ module.exports = __toCommonJS(exports_src);
71
+
72
+ // packages/idl/src/api/decorators/C3Decorator.ts
73
+ class C3Decorator {
74
+ type = "";
75
+ }
76
+ // packages/idl/src/api/decorators/NotNullDecorator.ts
77
+ class NotNullDecorator extends C3Decorator {
78
+ constructor() {
79
+ super();
80
+ this.type = "NotNull";
81
+ }
82
+ }
83
+ // packages/idl/src/api/C3Type.ts
84
+ class C3Type {
85
+ type = "";
86
+ constructor(type) {
87
+ this.type = type;
88
+ }
89
+ }
90
+
91
+ // packages/idl/src/api/ArrayC3Type.ts
92
+ class ArrayC3Type extends C3Type {
93
+ contains;
94
+ constructor(contains) {
95
+ super("array");
96
+ this.contains = contains;
97
+ }
98
+ }
99
+ // packages/idl/src/api/BooleanC3Type.ts
100
+ class BooleanC3Type extends C3Type {
101
+ constructor() {
102
+ super("boolean");
103
+ }
104
+ }
105
+ // packages/idl/src/api/ByteC3Type.ts
106
+ class ByteC3Type extends C3Type {
107
+ constructor() {
108
+ super("byte");
109
+ }
110
+ }
111
+ // packages/idl/src/api/CharC3Type.ts
112
+ class CharC3Type extends C3Type {
113
+ constructor() {
114
+ super("char");
115
+ }
116
+ }
117
+ // packages/idl/src/api/ComplexC3Type.ts
118
+ class ComplexC3Type extends C3Type {
119
+ name;
120
+ namespace;
121
+ decorators = null;
122
+ metadata;
123
+ constructor(type, name, namespace, decorators, metadata) {
124
+ super(type);
125
+ this.name = name;
126
+ this.namespace = namespace;
127
+ this.decorators = decorators;
128
+ this.metadata = metadata;
129
+ }
130
+ containsDecorator(value) {
131
+ return this.findDecorator(value) !== null;
132
+ }
133
+ hasDecorators() {
134
+ let ret = false;
135
+ if (this.decorators) {
136
+ ret = this.decorators.length > 0;
137
+ }
138
+ return ret;
139
+ }
140
+ addDecorator(decorator) {
141
+ if (!this.decorators) {
142
+ this.decorators = [];
143
+ } else {
144
+ if (this.containsDecorator(decorator)) {
145
+ throw new Error(`C3Base already contains decorator for name ${decorator.type}`);
146
+ }
147
+ }
148
+ this.decorators.push(decorator);
149
+ return this;
150
+ }
151
+ findDecorator(value) {
152
+ let ret = null;
153
+ if (this.decorators) {
154
+ for (const decorator of this.decorators) {
155
+ if (decorator.type === value.type) {
156
+ ret = decorator;
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ return ret;
162
+ }
163
+ getQualifiedName() {
164
+ return (this.namespace ? this.namespace + "." : "") + this.name;
165
+ }
166
+ }
167
+ // packages/idl/src/api/DateC3Type.ts
168
+ class DateC3Type extends C3Type {
169
+ constructor() {
170
+ super("date");
171
+ }
172
+ }
173
+ // packages/idl/src/api/DoubleC3Type.ts
174
+ class DoubleC3Type extends C3Type {
175
+ constructor() {
176
+ super("double");
177
+ }
178
+ }
179
+ // packages/idl/src/api/EnumC3Type.ts
180
+ class EnumC3Type extends ComplexC3Type {
181
+ values = [];
182
+ constructor(name, namespace, decorators, metadata) {
183
+ super("enum", name, namespace, decorators, metadata);
184
+ }
185
+ addValue(value) {
186
+ this.values.push(value);
187
+ return this;
188
+ }
189
+ }
190
+ // packages/idl/src/api/FloatC3Type.ts
191
+ class FloatC3Type extends C3Type {
192
+ constructor() {
193
+ super("float");
194
+ }
195
+ }
196
+ // packages/idl/src/api/AbstractDefinition.ts
197
+ class AbstractDefinition {
198
+ name;
199
+ decorators = null;
200
+ metadata = null;
201
+ constructor(name, decorators, metadata) {
202
+ this.name = name;
203
+ this.decorators = decorators;
204
+ this.metadata = metadata;
205
+ }
206
+ containsDecorator(value) {
207
+ return this.findDecorator(value) !== null;
208
+ }
209
+ hasDecorators() {
210
+ let ret = false;
211
+ if (this.decorators) {
212
+ ret = this.decorators.length > 0;
213
+ }
214
+ return ret;
215
+ }
216
+ addDecorator(decorator) {
217
+ if (!this.decorators) {
218
+ this.decorators = [];
219
+ } else {
220
+ if (this.containsDecorator(decorator)) {
221
+ throw new Error(`C3Base already contains decorator for name ${decorator.type}`);
222
+ }
223
+ }
224
+ this.decorators.push(decorator);
225
+ }
226
+ findDecorator(value) {
227
+ let ret = null;
228
+ if (this.decorators) {
229
+ for (const decorator of this.decorators) {
230
+ if (decorator.type === value.type) {
231
+ ret = decorator;
232
+ break;
233
+ }
234
+ }
235
+ }
236
+ return ret;
237
+ }
238
+ }
239
+
240
+ // packages/idl/src/api/ParameterDefinition.ts
241
+ class ParameterDefinition extends AbstractDefinition {
242
+ type;
243
+ constructor(name, type, decorators, metadata) {
244
+ super(name, decorators, metadata);
245
+ this.type = type;
246
+ }
247
+ }
248
+
249
+ // packages/idl/src/api/VoidC3Type.ts
250
+ class VoidC3Type extends C3Type {
251
+ constructor() {
252
+ super("void");
253
+ }
254
+ }
255
+
256
+ // packages/idl/src/api/FunctionDefinition.ts
257
+ class FunctionDefinition extends AbstractDefinition {
258
+ returnType = new VoidC3Type;
259
+ parameters = [];
260
+ constructor(name, decorators, metadata) {
261
+ super(name, decorators, metadata);
262
+ }
263
+ addParameter(name, c3Type, decorators) {
264
+ const param = new ParameterDefinition(name, c3Type, decorators);
265
+ if (this.parameters.find((value) => value.name === name)) {
266
+ throw new Error(`FunctionDefinition already contains parameter for name ${name}`);
267
+ }
268
+ this.parameters.push(param);
269
+ return this;
270
+ }
271
+ }
272
+ // packages/idl/src/api/IntC3Type.ts
273
+ class IntC3Type extends C3Type {
274
+ constructor() {
275
+ super("int");
276
+ }
277
+ }
278
+ // packages/idl/src/api/LongC3Type.ts
279
+ class LongC3Type extends C3Type {
280
+ constructor() {
281
+ super("long");
282
+ }
283
+ }
284
+ // packages/idl/src/api/MapC3Type.ts
285
+ class MapC3Type extends C3Type {
286
+ key = null;
287
+ value = null;
288
+ constructor() {
289
+ super("map");
290
+ }
291
+ }
292
+ // packages/idl/src/api/NamespaceDefinition.ts
293
+ class NamespaceDefinition {
294
+ name = "";
295
+ complexC3Types = new Set;
296
+ services = new Set;
297
+ addComplexC3Types(type) {
298
+ if (this.complexC3Types.has(type)) {
299
+ throw new Error(`This NamespaceSchema already contains an ComplexC3Type for name ${type.name}`);
300
+ }
301
+ this.complexC3Types.add(type);
302
+ return this;
303
+ }
304
+ addServiceSchema(service) {
305
+ if (this.services.has(service)) {
306
+ throw new Error(`This NamespaceSchema already contains an ServiceSchema for name ${service.name}`);
307
+ }
308
+ this.services.add(service);
309
+ return this;
310
+ }
311
+ }
312
+ // packages/idl/src/api/PropertyDefinition.ts
313
+ class PropertyDefinition extends AbstractDefinition {
314
+ type;
315
+ constructor(name, type, decorators, metadata) {
316
+ super(name, decorators, metadata);
317
+ this.type = type;
318
+ }
319
+ }
320
+
321
+ // packages/idl/src/api/ObjectC3Type.ts
322
+ class ObjectC3Type extends ComplexC3Type {
323
+ parent = null;
324
+ properties = [];
325
+ constructor(name, namespace, decorators, metadata) {
326
+ super("object", name, namespace, decorators, metadata);
327
+ }
328
+ addProperty(name, c3Type, decorators) {
329
+ return this.addPropertyDefinition(new PropertyDefinition(name, c3Type, decorators));
330
+ }
331
+ addPropertyDefinition(propertyDefinition) {
332
+ this.properties.push(propertyDefinition);
333
+ return this;
334
+ }
335
+ findProperty(name) {
336
+ let ret = null;
337
+ if (this.properties) {
338
+ for (const property of this.properties) {
339
+ if (property.name === name) {
340
+ ret = property;
341
+ break;
342
+ }
343
+ }
344
+ }
345
+ return ret;
346
+ }
347
+ }
348
+ // packages/idl/src/api/ReferenceC3Type.ts
349
+ class ReferenceC3Type extends C3Type {
350
+ qualifiedName = null;
351
+ constructor() {
352
+ super("ref");
353
+ }
354
+ }
355
+ // packages/idl/src/api/ServiceDefinition.ts
356
+ class ServiceDefinition extends AbstractDefinition {
357
+ namespace;
358
+ constructor(name, namespace, decorators, metadata) {
359
+ super(name, decorators, metadata);
360
+ this.namespace = namespace;
361
+ }
362
+ functions = new Set;
363
+ addFunction(func) {
364
+ if (this.functions.has(func)) {
365
+ throw new Error(`ServiceDefinition already contains function for name ${func.name}`);
366
+ }
367
+ this.functions.add(func);
368
+ return this;
369
+ }
370
+ getQualifiedName() {
371
+ return this.namespace + "." + this.name;
372
+ }
373
+ }
374
+ // packages/idl/src/api/ShortC3Type.ts
375
+ class ShortC3Type extends C3Type {
376
+ constructor() {
377
+ super("short");
378
+ }
379
+ }
380
+ // packages/idl/src/api/StringC3Type.ts
381
+ class StringC3Type extends C3Type {
382
+ constructor() {
383
+ super("string");
384
+ }
385
+ }
386
+ // packages/idl/src/api/UnionC3Type.ts
387
+ class UnionC3Type extends ComplexC3Type {
388
+ types = [];
389
+ constructor(name, namespace, decorators, metadata) {
390
+ super("union", name, namespace, decorators, metadata);
391
+ }
392
+ }