@typespec/compiler 0.61.0-dev.6 → 0.61.0-dev.8

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 (67) hide show
  1. package/dist/manifest.js +2 -2
  2. package/dist/src/core/numeric.js +1 -1
  3. package/dist/src/core/numeric.js.map +1 -1
  4. package/dist/src/core/program.d.ts.map +1 -1
  5. package/dist/src/core/program.js +2 -0
  6. package/dist/src/core/program.js.map +1 -1
  7. package/dist/src/experimental/index.d.ts +3 -0
  8. package/dist/src/experimental/index.d.ts.map +1 -1
  9. package/dist/src/experimental/index.js +3 -0
  10. package/dist/src/experimental/index.js.map +1 -1
  11. package/dist/src/experimental/mutators.d.ts +57 -0
  12. package/dist/src/experimental/mutators.d.ts.map +1 -0
  13. package/dist/src/experimental/mutators.js +173 -0
  14. package/dist/src/experimental/mutators.js.map +1 -0
  15. package/dist/src/experimental/realm.d.ts +34 -0
  16. package/dist/src/experimental/realm.d.ts.map +1 -0
  17. package/dist/src/experimental/realm.js +128 -0
  18. package/dist/src/experimental/realm.js.map +1 -0
  19. package/dist/src/experimental/typekit/define-kit.d.ts +28 -0
  20. package/dist/src/experimental/typekit/define-kit.d.ts.map +1 -0
  21. package/dist/src/experimental/typekit/define-kit.js +45 -0
  22. package/dist/src/experimental/typekit/define-kit.js.map +1 -0
  23. package/dist/src/experimental/typekit/index.d.ts +3 -0
  24. package/dist/src/experimental/typekit/index.d.ts.map +1 -0
  25. package/dist/src/experimental/typekit/index.js +3 -0
  26. package/dist/src/experimental/typekit/index.js.map +1 -0
  27. package/dist/src/experimental/typekit/kits/index.d.ts +9 -0
  28. package/dist/src/experimental/typekit/kits/index.d.ts.map +1 -0
  29. package/dist/src/experimental/typekit/kits/index.js +9 -0
  30. package/dist/src/experimental/typekit/kits/index.js.map +1 -0
  31. package/dist/src/experimental/typekit/kits/literal.d.ts +59 -0
  32. package/dist/src/experimental/typekit/kits/literal.d.ts.map +1 -0
  33. package/dist/src/experimental/typekit/kits/literal.js +51 -0
  34. package/dist/src/experimental/typekit/kits/literal.js.map +1 -0
  35. package/dist/src/experimental/typekit/kits/model-property.d.ts +45 -0
  36. package/dist/src/experimental/typekit/kits/model-property.d.ts.map +1 -0
  37. package/dist/src/experimental/typekit/kits/model-property.js +19 -0
  38. package/dist/src/experimental/typekit/kits/model-property.js.map +1 -0
  39. package/dist/src/experimental/typekit/kits/model.d.ts +48 -0
  40. package/dist/src/experimental/typekit/kits/model.d.ts.map +1 -0
  41. package/dist/src/experimental/typekit/kits/model.js +26 -0
  42. package/dist/src/experimental/typekit/kits/model.js.map +1 -0
  43. package/dist/src/experimental/typekit/kits/realm.d.ts +24 -0
  44. package/dist/src/experimental/typekit/kits/realm.d.ts.map +1 -0
  45. package/dist/src/experimental/typekit/kits/realm.js +17 -0
  46. package/dist/src/experimental/typekit/kits/realm.js.map +1 -0
  47. package/dist/src/experimental/typekit/kits/scalar.d.ts +354 -0
  48. package/dist/src/experimental/typekit/kits/scalar.d.ts.map +1 -0
  49. package/dist/src/experimental/typekit/kits/scalar.js +91 -0
  50. package/dist/src/experimental/typekit/kits/scalar.js.map +1 -0
  51. package/dist/src/experimental/typekit/kits/type.d.ts +25 -0
  52. package/dist/src/experimental/typekit/kits/type.d.ts.map +1 -0
  53. package/dist/src/experimental/typekit/kits/type.js +55 -0
  54. package/dist/src/experimental/typekit/kits/type.js.map +1 -0
  55. package/dist/src/experimental/typekit/kits/union-variant.d.ts +43 -0
  56. package/dist/src/experimental/typekit/kits/union-variant.d.ts.map +1 -0
  57. package/dist/src/experimental/typekit/kits/union-variant.js +22 -0
  58. package/dist/src/experimental/typekit/kits/union-variant.js.map +1 -0
  59. package/dist/src/experimental/typekit/kits/union.d.ts +56 -0
  60. package/dist/src/experimental/typekit/kits/union.d.ts.map +1 -0
  61. package/dist/src/experimental/typekit/kits/union.js +69 -0
  62. package/dist/src/experimental/typekit/kits/union.js.map +1 -0
  63. package/dist/src/experimental/typekit/utils.d.ts +8 -0
  64. package/dist/src/experimental/typekit/utils.d.ts.map +1 -0
  65. package/dist/src/experimental/typekit/utils.js +28 -0
  66. package/dist/src/experimental/typekit/utils.js.map +1 -0
  67. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import { type Program } from "../../core/program.js";
2
+ /** @experimental */
3
+ export declare function setCurrentProgram(program: Program): void;
4
+ /** @experimental */
5
+ export interface TypekitPrototype {
6
+ program: Program;
7
+ }
8
+ /** @experimental */
9
+ export declare const TypekitPrototype: Record<string, unknown>;
10
+ /** @experimental */
11
+ export declare function createTypekit(): TypekitPrototype;
12
+ /** @experimental */
13
+ export interface TypekitContext {
14
+ program: Program;
15
+ }
16
+ /**
17
+ * contextual typing to type guards is annoying (often have to restate the signature),
18
+ * so this helper will remove the type assertions from the interface you are currently defining.
19
+ * @experimental
20
+ */
21
+ export type StripGuards<T> = {
22
+ [K in keyof T]: T[K] extends (...args: infer P) => infer R ? (...args: P) => R : StripGuards<T[K]>;
23
+ };
24
+ /** @experimental */
25
+ export declare function defineKit<T extends Record<string, any>>(source: StripGuards<T> & ThisType<TypekitPrototype>): void;
26
+ /** @experimental */
27
+ export declare const $: TypekitPrototype;
28
+ //# sourceMappingURL=define-kit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-kit.d.ts","sourceRoot":"","sources":["../../../../src/experimental/typekit/define-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIrD,oBAAoB;AACpB,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD;AAED,oBAAoB;AACpB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,oBAAoB;AACpB,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AAE5D,oBAAoB;AACpB,wBAAgB,aAAa,IAAI,gBAAgB,CAkChD;AAED,oBAAoB;AACpB,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACtD,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACjB,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACtB,CAAC;AAEF,oBAAoB;AACpB,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrD,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAClD,IAAI,CAIN;AAED,oBAAoB;AACpB,eAAO,MAAM,CAAC,EAAE,gBAAkC,CAAC"}
@@ -0,0 +1,45 @@
1
+ let currentProgram;
2
+ /** @experimental */
3
+ export function setCurrentProgram(program) {
4
+ currentProgram = program;
5
+ }
6
+ /** @experimental */
7
+ export const TypekitPrototype = {};
8
+ /** @experimental */
9
+ export function createTypekit() {
10
+ const tk = Object.create(TypekitPrototype);
11
+ Object.defineProperty(tk, "program", {
12
+ get() {
13
+ return currentProgram;
14
+ },
15
+ });
16
+ const handler = {
17
+ get(target, prop, receiver) {
18
+ const value = Reflect.get(target, prop, receiver);
19
+ if (prop === "program") {
20
+ // don't wrap program (probably need to ensure this isn't a nested program somewhere)
21
+ return value;
22
+ }
23
+ if (typeof value === "function") {
24
+ return function (...args) {
25
+ return value.apply(proxy, args);
26
+ };
27
+ }
28
+ if (typeof value === "object" && value !== null) {
29
+ return new Proxy(value, handler);
30
+ }
31
+ return value;
32
+ },
33
+ };
34
+ const proxy = new Proxy(tk, handler);
35
+ return proxy;
36
+ }
37
+ /** @experimental */
38
+ export function defineKit(source) {
39
+ for (const [name, fnOrNs] of Object.entries(source)) {
40
+ TypekitPrototype[name] = fnOrNs;
41
+ }
42
+ }
43
+ /** @experimental */
44
+ export const $ = createTypekit();
45
+ //# sourceMappingURL=define-kit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-kit.js","sourceRoot":"","sources":["../../../../src/experimental/typekit/define-kit.ts"],"names":[],"mappings":"AAEA,IAAI,cAAmC,CAAC;AAExC,oBAAoB;AACpB,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAOD,oBAAoB;AACpB,MAAM,CAAC,MAAM,gBAAgB,GAA4B,EAAE,CAAC;AAE5D,oBAAoB;AACpB,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAE3C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE;QACnC,GAAG;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAmC;QAC9C,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAElD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,qFAAqF;gBACrF,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,UAAqB,GAAG,IAAW;oBACxC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBAClC,CAAC,CAAC;YACJ,CAAC;YAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAChD,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACnC,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;IAEF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAkBD,oBAAoB;AACpB,MAAM,UAAU,SAAS,CACvB,MAAmD;IAEnD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IAClC,CAAC;AACH,CAAC;AAED,oBAAoB;AACpB,MAAM,CAAC,MAAM,CAAC,GAAqB,aAAa,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./define-kit.js";
2
+ export * from "./kits/index.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/experimental/typekit/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./define-kit.js";
2
+ export * from "./kits/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/experimental/typekit/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from "./literal.js";
2
+ export * from "./model-property.js";
3
+ export * from "./model.js";
4
+ export * from "./realm.js";
5
+ export * from "./scalar.js";
6
+ export * from "./type.js";
7
+ export * from "./union-variant.js";
8
+ export * from "./union.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from "./literal.js";
2
+ export * from "./model-property.js";
3
+ export * from "./model.js";
4
+ export * from "./realm.js";
5
+ export * from "./scalar.js";
6
+ export * from "./type.js";
7
+ export * from "./union-variant.js";
8
+ export * from "./union.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { BooleanLiteral, NumericLiteral, StringLiteral, Type } from "../../../core/types.js";
2
+ interface LiteralKit {
3
+ literal: {
4
+ /**
5
+ * Create a literal type from a JavaScript value.
6
+ *
7
+ * @param value The JavaScript value to turn into a TypeSpec literal type.
8
+ */
9
+ create(value: string | number | boolean): StringLiteral | NumericLiteral | BooleanLiteral;
10
+ /**
11
+ * Create a string literal type from a JavaScript string value.
12
+ *
13
+ * @param value The string value.
14
+ */
15
+ createString(value: string): StringLiteral;
16
+ /**
17
+ * Create a numeric literal type from a JavaScript number value.
18
+ *
19
+ * @param value The numeric value.
20
+ */
21
+ createNumeric(value: number): NumericLiteral;
22
+ /**
23
+ * Create a boolean literal type from a JavaScript boolean value.
24
+ *
25
+ * @param value The boolean value.
26
+ */
27
+ createBoolean(value: boolean): BooleanLiteral;
28
+ /**
29
+ * Check if `type` is a literal type.
30
+ *
31
+ * @param type The type to check.
32
+ */
33
+ is(type: Type): type is StringLiteral | NumericLiteral | BooleanLiteral;
34
+ /**
35
+ * Check if `type` is a string literal type.
36
+ *
37
+ * @param type The type to check.
38
+ */
39
+ isString(type: Type): type is StringLiteral;
40
+ /**
41
+ * Check if `type` is a numeric literal type.
42
+ *
43
+ * @param type The type to check.
44
+ */
45
+ isNumeric(type: Type): type is NumericLiteral;
46
+ /**
47
+ * Check if `type` is a boolean literal type.
48
+ *
49
+ * @param type The type to check.
50
+ */
51
+ isBoolean(type: Type): type is BooleanLiteral;
52
+ };
53
+ }
54
+ declare module "../define-kit.js" {
55
+ interface TypekitPrototype extends LiteralKit {
56
+ }
57
+ }
58
+ export {};
59
+ //# sourceMappingURL=literal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/literal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGlG,UAAU,UAAU;IAClB,OAAO,EAAE;QACP;;;;WAIG;QACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC;QAE1F;;;;WAIG;QACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC;QAE3C;;;;WAIG;QACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC;QAE7C;;;;WAIG;QACH,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC;QAE9C;;;;WAIG;QACH,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC;QAExE;;;;WAIG;QACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,aAAa,CAAC;QAE5C;;;;WAIG;QACH,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,cAAc,CAAC;QAE9C;;;;WAIG;QACH,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,cAAc,CAAC;KAC/C,CAAC;CACH;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,gBAAiB,SAAQ,UAAU;KAAG;CACjD"}
@@ -0,0 +1,51 @@
1
+ import { Numeric } from "../../../core/numeric.js";
2
+ import { defineKit } from "../define-kit.js";
3
+ defineKit({
4
+ literal: {
5
+ create(value) {
6
+ if (typeof value === "string") {
7
+ return this.literal.createString(value);
8
+ }
9
+ else if (typeof value === "number") {
10
+ return this.literal.createNumeric(value);
11
+ }
12
+ else {
13
+ return this.literal.createBoolean(value);
14
+ }
15
+ },
16
+ createString(value) {
17
+ return this.program.checker.createType({
18
+ kind: "String",
19
+ value,
20
+ });
21
+ },
22
+ createNumeric(value) {
23
+ const valueAsString = String(value);
24
+ return this.program.checker.createType({
25
+ kind: "Number",
26
+ value,
27
+ valueAsString,
28
+ numericValue: Numeric(valueAsString),
29
+ });
30
+ },
31
+ createBoolean(value) {
32
+ return this.program.checker.createType({
33
+ kind: "Boolean",
34
+ value,
35
+ });
36
+ },
37
+ isBoolean(type) {
38
+ return type.kind === "Boolean";
39
+ },
40
+ isString(type) {
41
+ return type.kind === "String";
42
+ },
43
+ isNumeric(type) {
44
+ return type.kind === "Number";
45
+ },
46
+ is(type) {
47
+ return (this.literal.isBoolean(type) || this.literal.isNumeric(type) || this.literal.isString(type));
48
+ },
49
+ },
50
+ });
51
+ //# sourceMappingURL=literal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/literal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAkE7C,SAAS,CAAa;IACpB,OAAO,EAAE;QACP,MAAM,CAAC,KAAK;YACV,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QACD,YAAY,CAAC,KAAK;YAChB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;gBACrC,IAAI,EAAE,QAAQ;gBACd,KAAK;aACN,CAAC,CAAC;QACL,CAAC;QAED,aAAa,CAAC,KAAK;YACjB,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAEpC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;gBACrC,IAAI,EAAE,QAAQ;gBACd,KAAK;gBACL,aAAa;gBACb,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC;aACrC,CAAC,CAAC;QACL,CAAC;QAED,aAAa,CAAC,KAAK;YACjB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;gBACrC,IAAI,EAAE,SAAS;gBACf,KAAK;aACN,CAAC,CAAC;QACL,CAAC;QAED,SAAS,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;QACjC,CAAC;QACD,QAAQ,CAAC,IAAI;YACX,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;QAChC,CAAC;QACD,SAAS,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;QAChC,CAAC;QACD,EAAE,CAAC,IAAI;YACL,OAAO,CACL,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC5F,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { ModelProperty, Type } from "../../../core/types.js";
2
+ import { EncodeData } from "../../../lib/decorators.js";
3
+ export interface ModelPropertyKit {
4
+ /**
5
+ * Check if the given `type` is a model property.
6
+ *
7
+ * @param type The type to check.
8
+ */
9
+ is(type: Type): type is ModelProperty;
10
+ /**
11
+ * Get the encoding of the model property or its type. The property's type
12
+ * must be a scalar.
13
+ *
14
+ * @param property The model property to get the encoding for.
15
+ */
16
+ getEncoding(property: ModelProperty): EncodeData | undefined;
17
+ /**
18
+ * Get the format of the model property or its type. The property's type must
19
+ * be a string.
20
+ *
21
+ * @param property The model property to get the format for.
22
+ */
23
+ getFormat(property: ModelProperty): string | undefined;
24
+ /**
25
+ * Get the visibility of the model property.
26
+ */
27
+ getVisibility(property: ModelProperty): string[] | undefined;
28
+ }
29
+ interface TypeKit {
30
+ /**
31
+ * Utilities for working with model properties.
32
+ *
33
+ * For many reflection operations, the metadata being asked for may be found
34
+ * on the model property or the type of the model property. In such cases,
35
+ * these operations will return the metadata from the model property if it
36
+ * exists, or the type of the model property if it exists.
37
+ */
38
+ modelProperty: ModelPropertyKit;
39
+ }
40
+ declare module "../define-kit.js" {
41
+ interface TypekitPrototype extends TypeKit {
42
+ }
43
+ }
44
+ export {};
45
+ //# sourceMappingURL=model-property.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-property.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAU,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAuC,MAAM,4BAA4B,CAAC;AAG7F,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,aAAa,CAAC;IAEtC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;IAE7D;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;IAGvD;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9D;AAED,UAAU,OAAO;IACf;;;;;;;OAOG;IACH,aAAa,EAAE,gBAAgB,CAAC;CACjC;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,gBAAiB,SAAQ,OAAO;KAAG;CAC9C"}
@@ -0,0 +1,19 @@
1
+ import { getEncode, getFormat, getVisibility } from "../../../lib/decorators.js";
2
+ import { defineKit } from "../define-kit.js";
3
+ defineKit({
4
+ modelProperty: {
5
+ is(type) {
6
+ return type.kind === "ModelProperty";
7
+ },
8
+ getEncoding(type) {
9
+ return getEncode(this.program, type) ?? getEncode(this.program, type.type);
10
+ },
11
+ getFormat(type) {
12
+ return getFormat(this.program, type) ?? getFormat(this.program, type.type);
13
+ },
14
+ getVisibility(property) {
15
+ return getVisibility(this.program, property);
16
+ },
17
+ },
18
+ });
19
+ //# sourceMappingURL=model-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-property.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model-property.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiD7C,SAAS,CAAU;IACjB,aAAa,EAAE;QACb,EAAE,CAAC,IAAI;YACL,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC;QACvC,CAAC;QAED,WAAW,CAAC,IAAI;YACd,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAc,CAAC,CAAC;QACvF,CAAC;QAED,SAAS,CAAC,IAAI;YACZ,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAc,CAAC,CAAC;QACvF,CAAC;QAED,aAAa,CAAC,QAAQ;YACpB,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { Model, ModelProperty, SourceModel, Type } from "../../../core/types.js";
2
+ import { DecoratorArgs } from "../utils.js";
3
+ interface ModelDescriptor {
4
+ /**
5
+ * The name of the Model. If name is provided, it is a Model declaration.
6
+ * Otherwise, it is a Model expression.
7
+ */
8
+ name?: string;
9
+ /**
10
+ * Decorators to apply to the Model.
11
+ */
12
+ decorators?: DecoratorArgs[];
13
+ /**
14
+ * Properties of the model.
15
+ */
16
+ properties: Record<string, ModelProperty>;
17
+ /**
18
+ * Models that extend this model.
19
+ */
20
+ derivedModels?: Model[];
21
+ /**
22
+ * Models that this model extends.
23
+ */
24
+ sourceModels?: SourceModel[];
25
+ }
26
+ export interface ModelKit {
27
+ model: {
28
+ /**
29
+ * Create a model type.
30
+ *
31
+ * @param desc The descriptor of the model.
32
+ */
33
+ create(desc: ModelDescriptor): Model;
34
+ /**
35
+ * Check if the given `type` is a model..
36
+ *
37
+ * @param type The type to check.
38
+ */
39
+ is(type: Type): type is Model;
40
+ };
41
+ }
42
+ declare module "../define-kit.js" {
43
+ interface TypekitPrototype extends ModelKit {
44
+ }
45
+ }
46
+ export declare const ModelKit: void;
47
+ export {};
48
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGtF,OAAO,EAAwB,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,UAAU,eAAe;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE1C;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE;QACL;;;;WAIG;QACH,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,KAAK,CAAC;QAErC;;;;WAIG;QACH,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC;KAC/B,CAAC;CACH;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,gBAAiB,SAAQ,QAAQ;KAAG;CAC/C;AAED,eAAO,MAAM,QAAQ,MAuBnB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { createRekeyableMap } from "../../../utils/misc.js";
2
+ import { defineKit } from "../define-kit.js";
3
+ import { decoratorApplication } from "../utils.js";
4
+ export const ModelKit = defineKit({
5
+ model: {
6
+ create(desc) {
7
+ const properties = createRekeyableMap(Array.from(Object.entries(desc.properties)));
8
+ const model = this.program.checker.createType({
9
+ kind: "Model",
10
+ name: desc.name ?? "",
11
+ decorators: decoratorApplication(desc.decorators),
12
+ properties: properties,
13
+ expression: desc.name === undefined,
14
+ node: undefined,
15
+ derivedModels: desc.derivedModels ?? [],
16
+ sourceModels: desc.sourceModels ?? [],
17
+ });
18
+ this.program.checker.finishType(model);
19
+ return model;
20
+ },
21
+ is(type) {
22
+ return type.kind === "Model";
23
+ },
24
+ },
25
+ });
26
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAiB,MAAM,aAAa,CAAC;AAoDlE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAW;IAC1C,KAAK,EAAE;QACL,MAAM,CAAC,IAAI;YACT,MAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACnF,MAAM,KAAK,GAAU,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;gBACnD,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;gBACrB,UAAU,EAAE,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC;gBACjD,UAAU,EAAE,UAAU;gBACtB,UAAU,EAAE,IAAI,CAAC,IAAI,KAAK,SAAS;gBACnC,IAAI,EAAE,SAAgB;gBACtB,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE;gBACvC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE;aACtC,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,EAAE,CAAC,IAAI;YACL,OAAO,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;QAC/B,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Realm } from "../../realm.js";
2
+ /** @experimental */
3
+ export interface RealmKit {
4
+ /**
5
+ * Gets the current realm used by the typekit.
6
+ */
7
+ get(): Realm;
8
+ /**
9
+ * Sets the current realm to be used by the typekit.
10
+ */
11
+ set(realm: Realm): void;
12
+ }
13
+ interface BaseTypeKit {
14
+ /**
15
+ * Utilities for working with general types.
16
+ */
17
+ realm: RealmKit;
18
+ }
19
+ declare module "../define-kit.js" {
20
+ interface TypekitPrototype extends BaseTypeKit {
21
+ }
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=realm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realm.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/realm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,oBAAoB;AACpB,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,GAAG,IAAI,KAAK,CAAC;IACb;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACzB;AAED,UAAU,WAAW;IACnB;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,gBAAiB,SAAQ,WAAW;KAAG;CAClD"}
@@ -0,0 +1,17 @@
1
+ import { Realm } from "../../realm.js";
2
+ import { defineKit } from "../define-kit.js";
3
+ let _realm;
4
+ defineKit({
5
+ realm: {
6
+ get() {
7
+ if (!_realm) {
8
+ _realm = new Realm(this.program, " typekit realm");
9
+ }
10
+ return _realm;
11
+ },
12
+ set(realm) {
13
+ _realm = realm;
14
+ },
15
+ },
16
+ });
17
+ //# sourceMappingURL=realm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realm.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/realm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAyB7C,IAAI,MAAa,CAAC;AAElB,SAAS,CAAc;IACrB,KAAK,EAAE;QACL,GAAG;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;YACrD,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,GAAG,CAAC,KAAY;YACd,MAAM,GAAG,KAAK,CAAC;QACjB,CAAC;KACF;CACF,CAAC,CAAC"}