pi-proactive 0.2.0-beta.2 → 0.2.0-beta.3

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 (243) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +32 -28
  3. package/build/cli.mjs +121 -0
  4. package/build/extensions/proactive.js +47 -6
  5. package/build/src/commands.js +78 -2
  6. package/build/src/config.js +511 -4
  7. package/build/src/daemon-config.js +221 -0
  8. package/build/src/daemon-contact.js +103 -0
  9. package/build/src/daemon-host.js +84 -0
  10. package/build/src/daemon.js +193 -3
  11. package/build/src/health.js +84 -0
  12. package/build/src/lineage.js +41 -2
  13. package/build/src/notify.js +183 -0
  14. package/build/src/progress-eta.js +134 -0
  15. package/build/src/trigger.js +43 -0
  16. package/build/src/trust-loop.js +321 -0
  17. package/build/src/trust-metrics.js +236 -0
  18. package/build/src/trust-notify.js +73 -0
  19. package/build/src/trust-policy.js +58 -0
  20. package/build/src/trust-registry.js +323 -0
  21. package/daemon/launchd.plist +48 -0
  22. package/daemon/pi-proactive-daemon.service +29 -0
  23. package/daemon/run-daemon.sh +84 -0
  24. package/node_modules/typebox/build/compile/code.mjs +2 -1
  25. package/node_modules/typebox/build/compile/validator.mjs +1 -5
  26. package/node_modules/typebox/build/format/date_time.d.mts +1 -2
  27. package/node_modules/typebox/build/format/date_time.mjs +3 -12
  28. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  29. package/node_modules/typebox/build/format/duration.mjs +2 -2
  30. package/node_modules/typebox/build/format/idn_email.d.mts +0 -1
  31. package/node_modules/typebox/build/format/idn_email.mjs +0 -1
  32. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  33. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  34. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  35. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  36. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  37. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  38. package/node_modules/typebox/build/format/iri.mjs +9 -16
  39. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  40. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  41. package/node_modules/typebox/build/guard/emit.mjs +2 -2
  42. package/node_modules/typebox/build/guard/guard.d.mts +5 -7
  43. package/node_modules/typebox/build/guard/guard.mjs +9 -14
  44. package/node_modules/typebox/build/guard/index.mjs +0 -6
  45. package/node_modules/typebox/build/guard/{unicode/unicode_segment.mjs → string.mjs} +19 -16
  46. package/node_modules/typebox/build/schema/build.mjs +5 -5
  47. package/node_modules/typebox/build/schema/check.mjs +1 -1
  48. package/node_modules/typebox/build/schema/engine/_context.d.mts +1 -5
  49. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -16
  50. package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
  51. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
  52. package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
  53. package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
  54. package/node_modules/typebox/build/schema/engine/_refine.mjs +9 -14
  55. package/node_modules/typebox/build/schema/engine/_stack.d.mts +20 -34
  56. package/node_modules/typebox/build/schema/engine/_stack.mjs +202 -143
  57. package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -4
  58. package/node_modules/typebox/build/schema/engine/_unique.mjs +3 -7
  59. package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
  60. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  61. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -5
  62. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +32 -27
  63. package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
  64. package/node_modules/typebox/build/schema/engine/allOf.mjs +1 -1
  65. package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
  66. package/node_modules/typebox/build/schema/engine/anyOf.mjs +9 -4
  67. package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
  68. package/node_modules/typebox/build/schema/engine/boolean.mjs +6 -2
  69. package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
  70. package/node_modules/typebox/build/schema/engine/const.mjs +6 -2
  71. package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
  72. package/node_modules/typebox/build/schema/engine/contains.mjs +9 -5
  73. package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
  74. package/node_modules/typebox/build/schema/engine/dependencies.mjs +7 -5
  75. package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
  76. package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +6 -2
  77. package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
  78. package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +1 -2
  79. package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
  80. package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +8 -12
  81. package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
  82. package/node_modules/typebox/build/schema/engine/enum.mjs +6 -2
  83. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
  84. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +6 -2
  85. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
  86. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +6 -2
  87. package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
  88. package/node_modules/typebox/build/schema/engine/format.mjs +8 -11
  89. package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
  90. package/node_modules/typebox/build/schema/engine/if.mjs +13 -5
  91. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  92. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  93. package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
  94. package/node_modules/typebox/build/schema/engine/items.mjs +5 -8
  95. package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
  96. package/node_modules/typebox/build/schema/engine/maxContains.mjs +8 -4
  97. package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
  98. package/node_modules/typebox/build/schema/engine/maxItems.mjs +6 -2
  99. package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
  100. package/node_modules/typebox/build/schema/engine/maxLength.mjs +6 -2
  101. package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
  102. package/node_modules/typebox/build/schema/engine/maxProperties.mjs +6 -2
  103. package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
  104. package/node_modules/typebox/build/schema/engine/maximum.mjs +6 -2
  105. package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
  106. package/node_modules/typebox/build/schema/engine/minContains.mjs +9 -5
  107. package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
  108. package/node_modules/typebox/build/schema/engine/minItems.mjs +6 -2
  109. package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
  110. package/node_modules/typebox/build/schema/engine/minLength.mjs +6 -2
  111. package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
  112. package/node_modules/typebox/build/schema/engine/minProperties.mjs +6 -2
  113. package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
  114. package/node_modules/typebox/build/schema/engine/minimum.mjs +6 -2
  115. package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
  116. package/node_modules/typebox/build/schema/engine/multipleOf.mjs +6 -2
  117. package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
  118. package/node_modules/typebox/build/schema/engine/not.mjs +8 -4
  119. package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
  120. package/node_modules/typebox/build/schema/engine/oneOf.mjs +11 -6
  121. package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
  122. package/node_modules/typebox/build/schema/engine/pattern.mjs +7 -3
  123. package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
  124. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +5 -6
  125. package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
  126. package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
  127. package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
  128. package/node_modules/typebox/build/schema/engine/properties.mjs +3 -4
  129. package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
  130. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +10 -7
  131. package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
  132. package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +8 -12
  133. package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
  134. package/node_modules/typebox/build/schema/engine/ref.mjs +14 -18
  135. package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
  136. package/node_modules/typebox/build/schema/engine/required.mjs +6 -2
  137. package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
  138. package/node_modules/typebox/build/schema/engine/schema.mjs +138 -136
  139. package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
  140. package/node_modules/typebox/build/schema/engine/type.mjs +6 -2
  141. package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
  142. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +9 -5
  143. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
  144. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +9 -5
  145. package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
  146. package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +6 -2
  147. package/node_modules/typebox/build/schema/errors.mjs +1 -1
  148. package/node_modules/typebox/build/schema/intern/intern.d.mts +9 -6
  149. package/node_modules/typebox/build/schema/intern/intern.mjs +56 -90
  150. package/node_modules/typebox/build/schema/parse.mjs +0 -3
  151. package/node_modules/typebox/build/schema/pointer/pointer.d.mts +6 -1
  152. package/node_modules/typebox/build/schema/pointer/pointer.mjs +64 -47
  153. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +32 -6
  154. package/node_modules/typebox/build/schema/resolve/resolve.mjs +227 -231
  155. package/node_modules/typebox/build/schema/schema.d.mts +0 -1
  156. package/node_modules/typebox/build/schema/schema.mjs +0 -1
  157. package/node_modules/typebox/build/system/hashing/hash.mjs +34 -63
  158. package/node_modules/typebox/build/system/locale/en_US.mjs +1 -2
  159. package/node_modules/typebox/build/system/memory/assign.d.mts +8 -2
  160. package/node_modules/typebox/build/system/memory/assign.mjs +6 -13
  161. package/node_modules/typebox/build/system/memory/clone.d.mts +5 -4
  162. package/node_modules/typebox/build/system/memory/clone.mjs +96 -8
  163. package/node_modules/typebox/build/system/memory/create.d.mts +5 -1
  164. package/node_modules/typebox/build/system/memory/create.mjs +13 -18
  165. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  166. package/node_modules/typebox/build/system/memory/discard.mjs +8 -9
  167. package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
  168. package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
  169. package/node_modules/typebox/build/system/memory/update.d.mts +4 -1
  170. package/node_modules/typebox/build/system/memory/update.mjs +16 -43
  171. package/node_modules/typebox/build/system/settings/settings.d.mts +0 -11
  172. package/node_modules/typebox/build/system/settings/settings.mjs +0 -14
  173. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +24 -2
  174. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +29 -2
  175. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +0 -1
  176. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +0 -1
  177. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +1 -5
  178. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +1 -6
  179. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +3 -1
  180. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +4 -1
  181. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  182. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  183. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  184. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  185. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +3 -1
  186. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +4 -1
  187. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +3 -1
  188. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +4 -1
  189. package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
  190. package/node_modules/typebox/build/type/extends/inference.mjs +2 -15
  191. package/node_modules/typebox/build/type/extends/tuple.d.mts +1 -2
  192. package/node_modules/typebox/build/type/extends/tuple.mjs +1 -21
  193. package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
  194. package/node_modules/typebox/build/value/clone/clone.d.mts +3 -4
  195. package/node_modules/typebox/build/value/clone/clone.mjs +7 -5
  196. package/node_modules/typebox/build/value/parse/parse.mjs +4 -10
  197. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +14 -25
  198. package/node_modules/typebox/package.json +1 -1
  199. package/node_modules/typebox/readme.md +84 -52
  200. package/package.json +11 -3
  201. package/skills/pi-proactive/SKILL.md +27 -24
  202. package/tools/cli.mjs +121 -0
  203. package/tools/daemon-install.sh +397 -0
  204. package/tools/daemon-uninstall.sh +226 -0
  205. package/node_modules/typebox/build/guard/unicode/unicode.d.mts +0 -6
  206. package/node_modules/typebox/build/guard/unicode/unicode.mjs +0 -35
  207. package/node_modules/typebox/build/schema/engine/_pathing.d.mts +0 -1
  208. package/node_modules/typebox/build/schema/engine/_pathing.mjs +0 -11
  209. package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +0 -2
  210. package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +0 -288
  211. package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +0 -2
  212. package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +0 -300
  213. package/node_modules/typebox/build/schema/meta/draft_3.d.mts +0 -2
  214. package/node_modules/typebox/build/schema/meta/draft_3.mjs +0 -143
  215. package/node_modules/typebox/build/schema/meta/draft_4.d.mts +0 -2
  216. package/node_modules/typebox/build/schema/meta/draft_4.mjs +0 -149
  217. package/node_modules/typebox/build/schema/meta/draft_6.d.mts +0 -2
  218. package/node_modules/typebox/build/schema/meta/draft_6.mjs +0 -155
  219. package/node_modules/typebox/build/schema/meta/draft_7.d.mts +0 -2
  220. package/node_modules/typebox/build/schema/meta/draft_7.mjs +0 -172
  221. package/node_modules/typebox/build/schema/meta/index.d.mts +0 -2
  222. package/node_modules/typebox/build/schema/meta/index.mjs +0 -2
  223. package/node_modules/typebox/build/schema/meta/meta.d.mts +0 -9
  224. package/node_modules/typebox/build/schema/meta/meta.mjs +0 -15
  225. package/node_modules/typebox/build/schema/meta/schema.d.mts +0 -6
  226. package/node_modules/typebox/build/schema/meta/schema.mjs +0 -1
  227. package/node_modules/typebox/build/system/memory/deep.d.mts +0 -2
  228. package/node_modules/typebox/build/system/memory/deep.mjs +0 -108
  229. package/node_modules/typebox/build/system/memory/finalize.d.mts +0 -4
  230. package/node_modules/typebox/build/system/memory/finalize.mjs +0 -30
  231. package/node_modules/typebox/build/system/memory/keys.d.mts +0 -2
  232. package/node_modules/typebox/build/system/memory/keys.mjs +0 -8
  233. package/node_modules/typebox/build/system/settings/internal.d.mts +0 -2
  234. package/node_modules/typebox/build/system/settings/internal.mjs +0 -20
  235. package/node_modules/typebox/build/type/engine/call/index.d.mts +0 -1
  236. package/node_modules/typebox/build/type/engine/call/index.mjs +0 -1
  237. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +0 -30
  238. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +0 -29
  239. package/node_modules/typebox/build/type/engine/this/index.d.mts +0 -1
  240. package/node_modules/typebox/build/type/engine/this/index.mjs +0 -1
  241. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +0 -2
  242. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +0 -6
  243. /package/node_modules/typebox/build/guard/{unicode/unicode_segment.d.mts → string.d.mts} +0 -0
@@ -110,28 +110,15 @@ export class ErrorContext extends CheckContext {
110
110
  super();
111
111
  this.errors = [];
112
112
  }
113
- // ----------------------------------------------------------------
114
- // Public
115
- // ----------------------------------------------------------------
116
113
  AtCapacity() {
117
114
  return this.errors.length >= Settings.Get().maxErrors;
118
115
  }
119
- AddError(keyword, schemaPath, instancePath, params) {
120
- return this.AddErrorObject({ keyword, schemaPath, instancePath, params });
121
- }
122
- AddErrors(error) {
123
- error.forEach(error => this.AddErrorObject(error));
116
+ AddError(error) {
117
+ if (!this.AtCapacity())
118
+ this.errors.push(error);
124
119
  return false;
125
120
  }
126
121
  GetErrors() {
127
122
  return this.errors;
128
123
  }
129
- // ----------------------------------------------------------------
130
- // Private
131
- // ----------------------------------------------------------------
132
- AddErrorObject(error) {
133
- if (!this.AtCapacity())
134
- this.errors.push(error);
135
- return false;
136
- }
137
124
  }
@@ -1,6 +1,6 @@
1
1
  import * as Schema from '../types/index.mjs';
2
- import * as Stack from './_stack.mjs';
2
+ import { Stack } from './_stack.mjs';
3
3
  import { BuildContext } from './_context.mjs';
4
4
  export declare function ResetFunctions(): void;
5
5
  export declare function GetFunctions(): string[];
6
- export declare function CreateFunction(stack: Stack.XStack, context: BuildContext, schema: Schema.XSchema, value: string): string;
6
+ export declare function CreateFunction(stack: Stack, context: BuildContext, schema: Schema.XSchema, value: string): string;
@@ -55,7 +55,7 @@ export function GetFunctions() {
55
55
  // CreateFunction
56
56
  // ------------------------------------------------------------------
57
57
  export function CreateFunction(stack, context, schema, value) {
58
- const name = CreateName(schema, stack.lexicalBase);
58
+ const name = CreateName(schema, stack.LexicalBaseURL());
59
59
  const call = CreateCallExpression(context, schema, name, value);
60
60
  if (funcs.has(name))
61
61
  return call;
@@ -1,4 +1,4 @@
1
- import * as Schema from '../types/index.mjs';
2
- import * as Stack from './_stack.mjs';
1
+ import * as S from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
3
3
  import { BuildContext } from './_context.mjs';
4
- export declare function Reducer(stack: Stack.XStack, context: BuildContext, schemas: Schema.XSchema[], value: string, check: string): string;
4
+ export declare function Reducer(stack: Stack, context: BuildContext, schemas: S.XSchema[], value: string, check: string): string;
@@ -1,6 +1,6 @@
1
- import * as Schema from '../types/index.mjs';
2
- import * as Stack from './_stack.mjs';
1
+ import * as S from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
3
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
4
- export declare function BuildRefine(_stack: Stack.XStack, _context: BuildContext, schema: Schema.XRefine, value: string): string;
5
- export declare function CheckRefine(_stack: Stack.XStack, _context: CheckContext, schema: Schema.XRefine, value: unknown): boolean;
6
- export declare function ErrorRefine(_stack: Stack.XStack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XRefine, value: unknown): boolean;
4
+ export declare function BuildRefine(_stack: Stack, _context: BuildContext, schema: S.XRefine, value: string): string;
5
+ export declare function CheckRefine(_stack: Stack, _context: CheckContext, schema: S.XRefine, value: unknown): boolean;
6
+ export declare function ErrorRefine(_stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XRefine, value: unknown): boolean;
@@ -1,21 +1,12 @@
1
1
  // deno-fmt-ignore-file
2
- import * as Externals from './_externals.mjs';
2
+ import * as V from './_externals.mjs';
3
3
  import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Build
6
6
  // ------------------------------------------------------------------
7
- function BuildRefineMultiple(_stack, _context, schema, value) {
8
- const external = Externals.CreateVariable(schema['~refine']);
9
- return E.Every(external, E.Constant(0), ['refinement', '_'], E.Call(E.Member('refinement', 'check'), [value]));
10
- }
11
- function BuildRefineSingle(_stack, _context, schema, value) {
12
- const external = Externals.CreateVariable(schema['~refine'][0]);
13
- return E.Call(E.Member(external, 'check'), [value]);
14
- }
15
7
  export function BuildRefine(_stack, _context, schema, value) {
16
- return G.IsEqual(schema['~refine'].length, 1)
17
- ? BuildRefineSingle(_stack, _context, schema, value)
18
- : BuildRefineMultiple(_stack, _context, schema, value);
8
+ const refinements = V.CreateVariable(schema['~refine'].map((refinement) => refinement));
9
+ return E.Every(refinements, E.Constant(0), ['refinement', '_'], E.Call(E.Member('refinement', 'check'), [value]));
19
10
  }
20
11
  // ------------------------------------------------------------------
21
12
  // Check
@@ -28,7 +19,11 @@ export function CheckRefine(_stack, _context, schema, value) {
28
19
  // ------------------------------------------------------------------
29
20
  export function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
30
21
  return G.EveryAll(schema['~refine'], 0, (refinement, index) => {
31
- return refinement.check(value) ||
32
- context.AddError('~refine', schemaPath, instancePath, { index, message: refinement.error(value) });
22
+ return refinement.check(value) || context.AddError({
23
+ keyword: '~refine',
24
+ schemaPath,
25
+ instancePath,
26
+ params: { index, message: refinement.error(value) },
27
+ });
33
28
  });
34
29
  }
@@ -1,36 +1,22 @@
1
1
  import * as Schema from '../types/index.mjs';
2
- export declare const DefaultUri = "urn:typebox:root";
3
- export interface XStack {
4
- /** The schema context. */
5
- readonly context: Record<string, Schema.XSchema>;
6
- /** The entry schema. */
7
- readonly schema: Schema.XSchema;
8
- /** Visited $id schemas, kept only to detect resource re-entry (see resolve.ts FindResolvedResource). */
9
- readonly ids: Schema.XId[];
10
- /** Nearest enclosing $id schema, used as the root for local pointer resolution. */
11
- readonly lexicalSchema: Schema.XSchema;
12
- /** First $recursiveAnchor: true schema seen on the path. */
13
- readonly recursiveAnchor: Schema.XRecursiveAnchor | undefined;
14
- /** Dynamic anchors visible at this point in the traversal. */
15
- readonly dynamicAnchors: Schema.XDynamicAnchor[];
16
- /** Lexical base URL, used to resolve relative $id and $ref values within the current schema. */
17
- readonly lexicalBase: string;
18
- /** Base URL of the current resource, reset each time a new resource $id is entered. */
19
- readonly resourceBase: string;
20
- /** Base URL that $ref values resolve against. */
21
- readonly referenceBase: string;
22
- /** Resource entry point bookkeeping: schema -> the base/root to apply when that schema is next pushed. */
23
- readonly resourceEntries: Map<Schema.XSchemaObject, {
24
- base: string;
25
- root: Schema.XSchemaObject;
26
- }>;
27
- /** True while referenceBase should track resourceBase rather than lexicalBase. */
28
- readonly useResourceBaseForReference: boolean;
29
- /** True until the next $id schema is entered, marking it as a fresh resource root. */
30
- readonly pendingResource: boolean;
31
- /** True once traversal has entered a retrieved or legacy resource. */
32
- readonly enteredResource: boolean;
2
+ export declare class Stack {
3
+ #private;
4
+ private readonly context;
5
+ private readonly schema;
6
+ private readonly ids;
7
+ private readonly resourceIds;
8
+ private readonly anchors;
9
+ private readonly recursiveAnchors;
10
+ private readonly dynamicAnchors;
11
+ private readonly retrievedResources;
12
+ private readonly retrievedFrames;
13
+ private readonly resolvedResources;
14
+ private pendingResource;
15
+ constructor(context: Record<PropertyKey, Schema.XSchema>, schema: Schema.XSchema);
16
+ LexicalBaseURL(): string;
17
+ Push(schema: Schema.XSchema): void;
18
+ Pop(schema: Schema.XSchema): void;
19
+ Ref(ref: Schema.XRef): Schema.XSchema | undefined;
20
+ RecursiveRef(recursiveRef: Schema.XRecursiveRef): Schema.XSchema | undefined;
21
+ DynamicRef(dynamicRef: Schema.XDynamicRef): Schema.XSchema | undefined;
33
22
  }
34
- export declare function NextUri(ref: string, base: string): URL;
35
- export declare function Stack(context: Record<string, Schema.XSchema>, schema: Schema.XSchema): XStack;
36
- export declare function NextStack(stack: XStack, schema: Schema.XSchema): XStack;
@@ -1,150 +1,209 @@
1
- import { Guard } from '../../guard/index.mjs';
1
+ // deno-fmt-ignore-file
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _Stack_instances, _Stack_StackFrame, _Stack_ApplyRefResult, _Stack_BuildBase, _Stack_ResourceBaseURL, _Stack_ReferenceBaseURL, _Stack_LexicalSchema, _Stack_RegisterResourceAnchorArray, _Stack_UnregisterResourceAnchorArray, _Stack_RegisterResourceAnchors, _Stack_UnregisterResourceAnchors, _Stack_RegisterResource, _Stack_UnregisterResource, _Stack_EnterResolvedResource, _Stack_ExitResolvedResource;
2
8
  import * as Schema from '../types/index.mjs';
3
- // ------------------------------------------------------------------
4
- // DefaultUri
5
- // ------------------------------------------------------------------
6
- export const DefaultUri = 'urn:typebox:root';
7
- // ------------------------------------------------------------------
8
- // NextUri
9
- //
10
- // Resolves a relative or absolute ref against a base URI or URN.
11
- // Hierarchical bases (http, https, etc.) resolve using the normal
12
- // URL rules. URN bases have no path to resolve against, so the ref
13
- // is appended after the base's last ':' segment instead.
14
- // ------------------------------------------------------------------
15
- export function NextUri(ref, base) {
16
- return (URL.canParse(ref, base)) ? new URL(ref, base) : Guard.IsEqual(base, DefaultUri) ? new URL(`${base}:${ref}`) : new URL(`${base.slice(0, base.lastIndexOf(':'))}:${ref}`);
17
- }
18
- // ------------------------------------------------------------------
9
+ import { Guard } from '../../guard/index.mjs';
10
+ import { Resolve } from '../resolve/index.mjs';
11
+ // --------------------------------------------------------------------------
19
12
  // Stack
20
13
  //
21
- // Creates the root frame a schema traversal starts from.
22
- // ------------------------------------------------------------------
23
- export function Stack(context, schema) {
24
- const base = Schema.IsSchemaObject(schema) && Schema.IsId(schema) ? NextUri(schema.$id, DefaultUri).href : DefaultUri;
14
+ // Tracks traversal state ($ids, $anchors, stack frames) and applies scope
15
+ // updates. Reference resolution rules ($ref, $dynamicRef) are delegated to
16
+ // the Resolve functions using state snapshots (Resolve.Scope).
17
+ // --------------------------------------------------------------------------
18
+ export class Stack {
19
+ constructor(context, schema) {
20
+ _Stack_instances.add(this);
21
+ this.context = context;
22
+ this.schema = schema;
23
+ this.ids = [];
24
+ this.resourceIds = [];
25
+ this.anchors = [];
26
+ this.recursiveAnchors = [];
27
+ this.dynamicAnchors = [];
28
+ this.retrievedResources = new Map();
29
+ this.retrievedFrames = [];
30
+ this.resolvedResources = new Map();
31
+ this.pendingResource = true;
32
+ }
33
+ // ----------------------------------------------------------------
34
+ // LexicalBaseURL
35
+ // ----------------------------------------------------------------
36
+ LexicalBaseURL() {
37
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_BuildBase).call(this, this.ids);
38
+ }
39
+ // ----------------------------------------------------------------
40
+ // Push
41
+ // ----------------------------------------------------------------
42
+ Push(schema) {
43
+ if (!Schema.IsSchemaObject(schema))
44
+ return;
45
+ if (Schema.IsId(schema))
46
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResource).call(this, schema);
47
+ if (Schema.IsAnchor(schema))
48
+ this.anchors.push(schema);
49
+ if (Schema.IsRecursiveAnchorTrue(schema))
50
+ this.recursiveAnchors.push(schema);
51
+ if (Schema.IsDynamicAnchor(schema))
52
+ this.dynamicAnchors.push(schema);
53
+ const retrievedResource = this.retrievedResources.get(schema);
54
+ if (retrievedResource) {
55
+ this.retrievedFrames.push({
56
+ schema: retrievedResource.root,
57
+ base: retrievedResource.base,
58
+ idDepth: this.ids.length,
59
+ resourceDepth: this.resourceIds.length
60
+ });
61
+ }
62
+ }
63
+ // ----------------------------------------------------------------
64
+ // Pop
65
+ // ----------------------------------------------------------------
66
+ Pop(schema) {
67
+ if (!Schema.IsSchemaObject(schema))
68
+ return;
69
+ if (Schema.IsId(schema))
70
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResource).call(this, schema);
71
+ if (Schema.IsAnchor(schema))
72
+ this.anchors.pop();
73
+ if (Schema.IsRecursiveAnchorTrue(schema))
74
+ this.recursiveAnchors.pop();
75
+ if (Schema.IsDynamicAnchor(schema))
76
+ this.dynamicAnchors.pop();
77
+ if (this.retrievedResources.has(schema))
78
+ this.retrievedFrames.pop();
79
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ExitResolvedResource).call(this, schema);
80
+ }
81
+ // ----------------------------------------------------------------
82
+ // Ref
83
+ // ----------------------------------------------------------------
84
+ Ref(ref) {
85
+ const result = Resolve.ResolveRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), ref);
86
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ApplyRefResult).call(this, result);
87
+ return result.schema;
88
+ }
89
+ // ----------------------------------------------------------------
90
+ // RecursiveRef
91
+ // ----------------------------------------------------------------
92
+ RecursiveRef(recursiveRef) {
93
+ const result = Resolve.ResolveRecursiveRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), recursiveRef);
94
+ if (result)
95
+ this.pendingResource = true;
96
+ return result;
97
+ }
98
+ // ----------------------------------------------------------------
99
+ // DynamicRef
100
+ // ----------------------------------------------------------------
101
+ DynamicRef(dynamicRef) {
102
+ const result = Resolve.ResolveDynamicRef(__classPrivateFieldGet(this, _Stack_instances, "m", _Stack_StackFrame).call(this), dynamicRef);
103
+ if (result)
104
+ this.pendingResource = true;
105
+ return result;
106
+ }
107
+ }
108
+ _Stack_instances = new WeakSet(), _Stack_StackFrame = function _Stack_StackFrame() {
25
109
  return {
26
- context,
27
- schema,
28
- lexicalSchema: schema,
29
- lexicalBase: base,
30
- resourceBase: base,
31
- referenceBase: base,
32
- ids: [],
33
- useResourceBaseForReference: true,
34
- recursiveAnchor: undefined,
35
- dynamicAnchors: [],
36
- resourceEntries: new Map(),
37
- pendingResource: true,
38
- enteredResource: false
110
+ context: this.context,
111
+ root: this.schema,
112
+ ids: this.ids,
113
+ lexicalSchema: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_LexicalSchema).call(this),
114
+ lexicalBase: this.LexicalBaseURL(),
115
+ referenceBase: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ReferenceBaseURL).call(this),
116
+ resourceBase: __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this),
117
+ recursiveAnchors: this.recursiveAnchors,
118
+ dynamicAnchors: this.dynamicAnchors,
119
+ inRetrievedFrame: this.retrievedFrames.length > 0
39
120
  };
40
- }
41
- // ------------------------------------------------------------------
42
- // RegisterResourceAnchors
43
- //
44
- // Collects $dynamicAnchor schemas reachable from a resource root,
45
- // stopping at nested $id boundaries which own their own anchors.
46
- // ------------------------------------------------------------------
47
- function RegisterResourceAnchors(anchors, schema, isRoot = true) {
121
+ }, _Stack_ApplyRefResult = function _Stack_ApplyRefResult(result) {
122
+ if (!Guard.IsUndefined(result.schema))
123
+ this.pendingResource = true;
124
+ if (!Guard.IsUndefined(result.resolvedResource)) {
125
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_EnterResolvedResource).call(this, result.resolvedResource.target, result.resolvedResource.resource);
126
+ }
127
+ if (!Guard.IsUndefined(result.retrievedResource)) {
128
+ this.retrievedResources.set(result.retrievedResource.target, {
129
+ base: result.retrievedResource.base,
130
+ root: result.retrievedResource.root
131
+ });
132
+ }
133
+ }, _Stack_BuildBase = function _Stack_BuildBase(stack) {
134
+ const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
135
+ const base = frame ? new URL(frame.base) : new URL(Resolve.DefaultBase);
136
+ const scoped = frame ? stack.slice(frame.idDepth) : stack;
137
+ return scoped.reduce((result, schema) => new URL(schema.$id, result), base).href;
138
+ }, _Stack_ResourceBaseURL = function _Stack_ResourceBaseURL() {
139
+ const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
140
+ if (!frame)
141
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_BuildBase).call(this, this.resourceIds);
142
+ return this.resourceIds.slice(frame.resourceDepth).reduce((result, schema) => new URL(schema.$id, result), new URL(frame.base)).href;
143
+ }, _Stack_ReferenceBaseURL = function _Stack_ReferenceBaseURL() {
144
+ if (this.retrievedFrames.length > 0)
145
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this);
146
+ const lexical = this.ids[this.ids.length - 1];
147
+ if (lexical && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(lexical.$id))
148
+ return this.LexicalBaseURL();
149
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_ResourceBaseURL).call(this);
150
+ }, _Stack_LexicalSchema = function _Stack_LexicalSchema() {
151
+ const frame = this.retrievedFrames[this.retrievedFrames.length - 1];
152
+ if (frame)
153
+ return this.ids.length > frame.idDepth ? this.ids[this.ids.length - 1] : frame.schema;
154
+ return this.ids.length > 0 ? this.ids[this.ids.length - 1] : this.schema;
155
+ }, _Stack_RegisterResourceAnchorArray = function _Stack_RegisterResourceAnchorArray(schema) {
156
+ schema.forEach((schema) => __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, schema, false));
157
+ }, _Stack_UnregisterResourceAnchorArray = function _Stack_UnregisterResourceAnchorArray(schema) {
158
+ schema.forEach((schema) => __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, schema, false));
159
+ }, _Stack_RegisterResourceAnchors = function _Stack_RegisterResourceAnchors(schema, isRoot = true) {
48
160
  if (Schema.IsSchemaBoolean(schema))
49
- return anchors;
50
- if (Array.isArray(schema))
51
- return schema.reduce((result, item) => RegisterResourceAnchors(result, item, false), anchors);
161
+ return;
162
+ if (Guard.IsArray(schema))
163
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchorArray).call(this, schema);
52
164
  if (!Schema.IsSchemaObject(schema))
53
- return anchors;
54
- if (!isRoot && Schema.IsId(schema))
55
- return anchors;
56
- const next = !isRoot && Schema.IsDynamicAnchor(schema) ? [...anchors, schema] : anchors;
57
- return Object.keys(schema).reduce((result, key) => RegisterResourceAnchors(result, schema[key], false), next);
58
- }
59
- // ------------------------------------------------------------------
60
- // ResourceEntry
61
- //
62
- // A ref crossing (Resolve.Ref) may have marked `schema` as the entry
63
- // point of a retrieved/legacy resource. If so the frame resets to
64
- // that resource's base/root instead of chaining onto the parent.
65
- // ------------------------------------------------------------------
66
- function ResourceEntry(stack, schema) {
67
- return stack.resourceEntries.get(schema);
68
- }
69
- function NextEnteredResource(stack, schema) {
70
- return stack.enteredResource || ResourceEntry(stack, schema) !== undefined;
71
- }
72
- // ------------------------------------------------------------------
73
- // NextStack
74
- //
75
- // Each Next* helper below computes one XStack field in isolation from
76
- // the previous frame and the schema being pushed.
77
- // ------------------------------------------------------------------
78
- function IsRelativeId(schema) {
79
- return !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(schema.$id);
80
- }
81
- function NextIds(stack, schema) {
82
- return Schema.IsId(schema) ? [...stack.ids, schema] : stack.ids;
83
- }
84
- function NextRecursiveAnchor(stack, schema) {
85
- return stack.recursiveAnchor ?? (Schema.IsRecursiveAnchorTrue(schema) ? schema : undefined);
86
- }
87
- function NextDynamicAnchors(stack, schema) {
88
- const registered = Schema.IsId(schema) ? RegisterResourceAnchors(stack.dynamicAnchors, schema) : stack.dynamicAnchors;
89
- return Schema.IsDynamicAnchor(schema) ? [...registered, schema] : registered;
90
- }
91
- function NextPendingResource(stack, schema) {
92
- return Schema.IsId(schema) ? false : stack.pendingResource;
93
- }
94
- function NextLexicalBase(stack, schema) {
95
- const entry = ResourceEntry(stack, schema);
96
- if (entry)
97
- return entry.base;
98
- return Schema.IsId(schema) ? NextUri(schema.$id, stack.lexicalBase).href : stack.lexicalBase;
99
- }
100
- function NextResourceBase(stack, schema) {
101
- const entry = ResourceEntry(stack, schema);
102
- if (entry)
103
- return entry.base;
104
- return (Schema.IsId(schema) && stack.pendingResource) ? NextUri(schema.$id, stack.resourceBase).href : stack.resourceBase;
105
- }
106
- function NextUseResourceBaseForReference(stack, schema) {
107
- return Schema.IsId(schema) ? !IsRelativeId(schema) : stack.useResourceBaseForReference;
108
- }
109
- function NextReferenceBase(stack, schema) {
110
- const isRetrieved = NextEnteredResource(stack, schema);
111
- const useResourceBaseForReference = NextUseResourceBaseForReference(stack, schema);
112
- return (isRetrieved || useResourceBaseForReference) ? NextResourceBase(stack, schema) : NextLexicalBase(stack, schema);
113
- }
114
- function NextLexicalSchema(stack, schema) {
115
- const entry = ResourceEntry(stack, schema);
116
- if (entry)
117
- return entry.root;
118
- return Schema.IsId(schema) ? schema : stack.lexicalSchema;
119
- }
120
- // ------------------------------------------------------------------
121
- // NextStack | HasStackKeywords (Optimization)
122
- //
123
- // HasStackKeywords narrows schema to an object and checks whether it
124
- // carries $id, $dynamicAnchor, a first-seen $recursiveAnchor, or a
125
- // resource-entry point. When none apply, NextStack skips the frame
126
- // rebuild and returns the parent stack as-is.
127
- // ------------------------------------------------------------------
128
- function HasStackKeywords(stack, schema) {
129
- return Schema.IsSchemaObject(schema) && (Schema.IsId(schema) ||
130
- Schema.IsDynamicAnchor(schema) ||
131
- (Guard.IsUndefined(stack.recursiveAnchor) && Schema.IsRecursiveAnchorTrue(schema)) ||
132
- !Guard.IsUndefined(ResourceEntry(stack, schema)));
133
- }
134
- export function NextStack(stack, schema) {
135
- return HasStackKeywords(stack, schema)
136
- ? {
137
- ...stack,
138
- ids: NextIds(stack, schema),
139
- dynamicAnchors: NextDynamicAnchors(stack, schema),
140
- recursiveAnchor: NextRecursiveAnchor(stack, schema),
141
- pendingResource: NextPendingResource(stack, schema),
142
- lexicalBase: NextLexicalBase(stack, schema),
143
- resourceBase: NextResourceBase(stack, schema),
144
- useResourceBaseForReference: NextUseResourceBaseForReference(stack, schema),
145
- referenceBase: NextReferenceBase(stack, schema),
146
- lexicalSchema: NextLexicalSchema(stack, schema),
147
- enteredResource: NextEnteredResource(stack, schema)
148
- }
149
- : stack;
150
- }
165
+ return;
166
+ const current = schema;
167
+ if (!isRoot && Schema.IsId(current))
168
+ return;
169
+ if (!isRoot && Schema.IsDynamicAnchor(current))
170
+ this.dynamicAnchors.push(current);
171
+ for (const key of Guard.Keys(current))
172
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, current[key], false);
173
+ }, _Stack_UnregisterResourceAnchors = function _Stack_UnregisterResourceAnchors(schema, isRoot = true) {
174
+ if (Schema.IsSchemaBoolean(schema))
175
+ return;
176
+ if (Guard.IsArray(schema))
177
+ return __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchorArray).call(this, schema);
178
+ if (!Schema.IsSchemaObject(schema))
179
+ return;
180
+ const current = schema;
181
+ if (!isRoot && Schema.IsId(current))
182
+ return;
183
+ if (!isRoot && Schema.IsDynamicAnchor(current))
184
+ this.dynamicAnchors.pop();
185
+ for (const key of Guard.Keys(current))
186
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, current[key], false);
187
+ }, _Stack_RegisterResource = function _Stack_RegisterResource(schema) {
188
+ this.ids.push(schema);
189
+ const isResource = this.pendingResource;
190
+ this.pendingResource = false;
191
+ if (isResource)
192
+ this.resourceIds.push(schema);
193
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResourceAnchors).call(this, schema, true);
194
+ }, _Stack_UnregisterResource = function _Stack_UnregisterResource(schema) {
195
+ this.ids.pop();
196
+ const isResource = this.resourceIds.length > 0 && Guard.IsEqual(this.resourceIds[this.resourceIds.length - 1], schema);
197
+ if (isResource)
198
+ this.resourceIds.pop();
199
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResourceAnchors).call(this, schema, true);
200
+ }, _Stack_EnterResolvedResource = function _Stack_EnterResolvedResource(target, resource) {
201
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_RegisterResource).call(this, resource);
202
+ this.resolvedResources.set(target, resource);
203
+ }, _Stack_ExitResolvedResource = function _Stack_ExitResolvedResource(target) {
204
+ if (!this.resolvedResources.has(target))
205
+ return;
206
+ const resource = this.resolvedResources.get(target);
207
+ __classPrivateFieldGet(this, _Stack_instances, "m", _Stack_UnregisterResource).call(this, resource);
208
+ this.resolvedResources.delete(target);
209
+ };
@@ -1,4 +1,2 @@
1
- /** Creates a unique variable name */
2
- export declare function CreateUnique(): string;
3
- /** Resets the unique variable name counter */
4
- export declare function ResetUnique(): void;
1
+ /** Returns a Unique Variable Name */
2
+ export declare function Unique(): string;
@@ -1,9 +1,5 @@
1
1
  let index = 0;
2
- /** Creates a unique variable name */
3
- export function CreateUnique() {
4
- return `unique_${index++}`;
5
- }
6
- /** Resets the unique variable name counter */
7
- export function ResetUnique() {
8
- index = 0;
2
+ /** Returns a Unique Variable Name */
3
+ export function Unique() {
4
+ return `var_${index++}`;
9
5
  }
@@ -1,6 +1,6 @@
1
1
  import * as Schema from '../types/index.mjs';
2
- import * as Stack from './_stack.mjs';
2
+ import { Stack } from './_stack.mjs';
3
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
4
- export declare function BuildAdditionalItems(stack: Stack.XStack, context: BuildContext, schema: Schema.XAdditionalItems, value: string): string;
5
- export declare function CheckAdditionalItems(stack: Stack.XStack, context: CheckContext, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
6
- export declare function ErrorAdditionalItems(stack: Stack.XStack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
4
+ export declare function BuildAdditionalItems(stack: Stack, context: BuildContext, schema: Schema.XAdditionalItems, value: string): string;
5
+ export declare function CheckAdditionalItems(stack: Stack, context: CheckContext, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
6
+ export declare function ErrorAdditionalItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XAdditionalItems, value: unknown[]): boolean;
@@ -1,6 +1,6 @@
1
1
  // deno-fmt-ignore-file
2
2
  import * as Schema from '../types/index.mjs';
3
- import * as Unique from './_unique.mjs';
3
+ import { Unique } from './_unique.mjs';
4
4
  import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
5
5
  import { BuildSchemaPushStack, CheckSchemaPushStack, ErrorSchemaPushStack } from './schema.mjs';
6
6
  // ------------------------------------------------------------------
@@ -13,14 +13,14 @@ function IsValid(schema) {
13
13
  // Build
14
14
  // ------------------------------------------------------------------
15
15
  function BuildAdditionalItemsStandard(stack, context, schema, value) {
16
- const [item, index] = [Unique.CreateUnique(), Unique.CreateUnique()];
16
+ const [item, index] = [Unique(), Unique()];
17
17
  const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
18
18
  const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
19
19
  const addIndex = context.AddIndex(index);
20
20
  return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, E.And(isSchema, addIndex)));
21
21
  }
22
22
  function BuildAdditionalItemsFast(stack, context, schema, value) {
23
- const [item, index] = [Unique.CreateUnique(), Unique.CreateUnique()];
23
+ const [item, index] = [Unique(), Unique()];
24
24
  const isSchema = BuildSchemaPushStack(stack, context, schema.additionalItems, item);
25
25
  const isLength = E.IsLessThan(index, E.Constant(schema.items.length));
26
26
  return E.Every(value, E.Constant(0), [item, index], E.Or(isLength, isSchema));
@@ -1,6 +1,9 @@
1
- import * as Schema from '../types/index.mjs';
2
- import * as Stack from './_stack.mjs';
1
+ import * as S from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
3
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
4
- export declare function BuildAdditionalProperties(stack: Stack.XStack, context: BuildContext, schema: Schema.XAdditionalProperties, value: string): string;
5
- export declare function CheckAdditionalProperties(stack: Stack.XStack, context: CheckContext, schema: Schema.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;
6
- export declare function ErrorAdditionalProperties(stack: Stack.XStack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;
4
+ export declare function CanAdditionalPropertiesFast(_context: BuildContext, schema: S.XAdditionalProperties, _value: string): schema is S.XAdditionalProperties & S.XRequired;
5
+ export declare function BuildAdditionalPropertiesFast(_context: BuildContext, schema: S.XAdditionalProperties & S.XRequired, value: string): string;
6
+ export declare function BuildAdditionalPropertiesStandard(stack: Stack, context: BuildContext, schema: S.XAdditionalProperties, value: string): string;
7
+ export declare function BuildAdditionalProperties(stack: Stack, context: BuildContext, schema: S.XAdditionalProperties, value: string): string;
8
+ export declare function CheckAdditionalProperties(stack: Stack, context: CheckContext, schema: S.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;
9
+ export declare function ErrorAdditionalProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XAdditionalProperties, value: Record<PropertyKey, unknown>): boolean;