@atscript/core 0.1.91 → 0.1.93
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 +37 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.mjs +36 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5274,6 +5274,28 @@ var AtscriptRepo = class {
|
|
|
5274
5274
|
}
|
|
5275
5275
|
return atscript;
|
|
5276
5276
|
}
|
|
5277
|
+
/**
|
|
5278
|
+
* Drops the cached document for `id` and detaches it from its dependencies
|
|
5279
|
+
* (which also removes it from each dependency's `dependants`).
|
|
5280
|
+
*
|
|
5281
|
+
* Documents are cached forever and an imported document is read from disk
|
|
5282
|
+
* only once, so a file that changed outside the repo (a watcher, a dev
|
|
5283
|
+
* server, an editor) keeps resolving to its stale parse until it is closed.
|
|
5284
|
+
* After closing, the next `openDocument(id)` without text re-reads the file.
|
|
5285
|
+
*
|
|
5286
|
+
* Dependants are left untouched on purpose: their next `checkDoc` re-runs
|
|
5287
|
+
* `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
|
|
5288
|
+
* their `dependenciesMap` to the fresh document.
|
|
5289
|
+
*
|
|
5290
|
+
* @returns `true` when a cached document was dropped, `false` when nothing
|
|
5291
|
+
* was cached under `id`.
|
|
5292
|
+
*/ closeDocument(id) {
|
|
5293
|
+
const cached = this.atscripts.get(id);
|
|
5294
|
+
if (!cached) return false;
|
|
5295
|
+
this.atscripts.delete(id);
|
|
5296
|
+
cached.then((d) => d.updateDependencies([]), () => {});
|
|
5297
|
+
return true;
|
|
5298
|
+
}
|
|
5277
5299
|
async _openDocument(id, text) {
|
|
5278
5300
|
const { manager } = await this.resolveConfig(id);
|
|
5279
5301
|
const newId = await manager.resolve(id);
|
|
@@ -5547,6 +5569,19 @@ function hasNavPropAnnotation(prop) {
|
|
|
5547
5569
|
if (!prop.annotations) return false;
|
|
5548
5570
|
return prop.annotations.some((a) => a.name === "db.rel.to" || a.name === "db.rel.from" || a.name === "db.rel.via");
|
|
5549
5571
|
}
|
|
5572
|
+
/**
|
|
5573
|
+
* Annotations that make an interface a DB entity — a table, or a managed view.
|
|
5574
|
+
* `@db.view.for` alone declares a managed view (`@db.view`, the name, is
|
|
5575
|
+
* optional), so codegen (`__flat` / `__ownProps`), the `asc db sync` inventory
|
|
5576
|
+
* and `DbSpace.get()` in `@atscript/db` all share this one rule.
|
|
5577
|
+
*/ const DB_ENTITY_ANNOTATIONS = [
|
|
5578
|
+
"db.table",
|
|
5579
|
+
"db.view",
|
|
5580
|
+
"db.view.for"
|
|
5581
|
+
];
|
|
5582
|
+
/** AST side of {@link DB_ENTITY_ANNOTATIONS}: whether a node carries a DB-entity annotation. */ function isDbEntityNode(node) {
|
|
5583
|
+
return !!node.annotations?.some((a) => DB_ENTITY_ANNOTATIONS.some((name) => name === a.name));
|
|
5584
|
+
}
|
|
5550
5585
|
function isPhantomNode(doc, def) {
|
|
5551
5586
|
if (!def) return false;
|
|
5552
5587
|
if (isPrimitive(def) && def.config.type === "phantom") return true;
|
|
@@ -5774,6 +5809,7 @@ exports.AnnotationSpec = AnnotationSpec;
|
|
|
5774
5809
|
exports.AtscriptDoc = AtscriptDoc;
|
|
5775
5810
|
exports.AtscriptRepo = AtscriptRepo;
|
|
5776
5811
|
exports.BuildRepo = BuildRepo;
|
|
5812
|
+
exports.DB_ENTITY_ANNOTATIONS = DB_ENTITY_ANNOTATIONS;
|
|
5777
5813
|
exports.DEFAULT_FORMAT = DEFAULT_FORMAT;
|
|
5778
5814
|
exports.PluginManager = PluginManager;
|
|
5779
5815
|
exports.SemanticAnnotateNode = SemanticAnnotateNode;
|
|
@@ -5814,6 +5850,7 @@ exports.isArray = isArray;
|
|
|
5814
5850
|
exports.isBareId = isBareId;
|
|
5815
5851
|
exports.isBareSpecifier = isBareSpecifier;
|
|
5816
5852
|
exports.isConst = isConst;
|
|
5853
|
+
exports.isDbEntityNode = isDbEntityNode;
|
|
5817
5854
|
exports.isGroup = isGroup;
|
|
5818
5855
|
exports.isImport = isImport;
|
|
5819
5856
|
exports.isInterface = isInterface;
|
package/dist/index.d.ts
CHANGED
|
@@ -157,6 +157,23 @@ declare class AtscriptRepo {
|
|
|
157
157
|
loadPluginManagerFor(id: string): Promise<TPluginManagers>;
|
|
158
158
|
resolveConfig(id: string): Promise<TPluginManagers>;
|
|
159
159
|
openDocument(id: string, text?: string): Promise<AtscriptDoc>;
|
|
160
|
+
/**
|
|
161
|
+
* Drops the cached document for `id` and detaches it from its dependencies
|
|
162
|
+
* (which also removes it from each dependency's `dependants`).
|
|
163
|
+
*
|
|
164
|
+
* Documents are cached forever and an imported document is read from disk
|
|
165
|
+
* only once, so a file that changed outside the repo (a watcher, a dev
|
|
166
|
+
* server, an editor) keeps resolving to its stale parse until it is closed.
|
|
167
|
+
* After closing, the next `openDocument(id)` without text re-reads the file.
|
|
168
|
+
*
|
|
169
|
+
* Dependants are left untouched on purpose: their next `checkDoc` re-runs
|
|
170
|
+
* `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
|
|
171
|
+
* their `dependenciesMap` to the fresh document.
|
|
172
|
+
*
|
|
173
|
+
* @returns `true` when a cached document was dropped, `false` when nothing
|
|
174
|
+
* was cached under `id`.
|
|
175
|
+
*/
|
|
176
|
+
closeDocument(id: string): boolean;
|
|
160
177
|
protected _openDocument(id: string, text?: string): Promise<AtscriptDoc>;
|
|
161
178
|
checkDoc(atscript: AtscriptDoc): Promise<void>;
|
|
162
179
|
checkImports(atscript: AtscriptDoc, checked?: Set<string>): Promise<void>;
|
|
@@ -1052,6 +1069,15 @@ interface TFlattenOptions {
|
|
|
1052
1069
|
*/
|
|
1053
1070
|
declare function flattenInterfaceNode(doc: AtscriptDoc, node: SemanticInterfaceNode, options?: TFlattenOptions): Map<string, TFlatFieldDescriptor>;
|
|
1054
1071
|
declare function hasNavPropAnnotation(prop: SemanticPropNode): boolean;
|
|
1072
|
+
/**
|
|
1073
|
+
* Annotations that make an interface a DB entity — a table, or a managed view.
|
|
1074
|
+
* `@db.view.for` alone declares a managed view (`@db.view`, the name, is
|
|
1075
|
+
* optional), so codegen (`__flat` / `__ownProps`), the `asc db sync` inventory
|
|
1076
|
+
* and `DbSpace.get()` in `@atscript/db` all share this one rule.
|
|
1077
|
+
*/
|
|
1078
|
+
declare const DB_ENTITY_ANNOTATIONS: readonly ["db.table", "db.view", "db.view.for"];
|
|
1079
|
+
/** AST side of {@link DB_ENTITY_ANNOTATIONS}: whether a node carries a DB-entity annotation. */
|
|
1080
|
+
declare function isDbEntityNode(node: SemanticNode): boolean;
|
|
1055
1081
|
declare function isPhantomNode(doc: AtscriptDoc, def?: SemanticNode): boolean;
|
|
1056
1082
|
|
|
1057
1083
|
interface TQueryScope {
|
|
@@ -1103,5 +1129,5 @@ type TQueryCursorContext = {
|
|
|
1103
1129
|
*/
|
|
1104
1130
|
declare function analyzeQueryCursorContext(textBeforeCursor: string): TQueryCursorContext;
|
|
1105
1131
|
|
|
1106
|
-
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
1132
|
+
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DB_ENTITY_ANNOTATIONS, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
1107
1133
|
export type { SemanticQueryExprNode, TAnnotationArgument, TAnnotationSpecConfig, TAnnotationTokens, TAnnotationsTree, TAtscriptConfig, TAtscriptConfigInput, TAtscriptConfigOutput, TAtscriptDocConfig, TAtscriptPlugin, TAtscriptRenderFormat, TDbConfig, TDbConfigDeclarative, TFlatFieldDescriptor, TFlattenOptions, TMessages, TNodeEntity, TOutput, TOutputWithSource, TPluginManagers, TPluginOutput, TPrimitiveAnnotationArg, TPrimitiveAnnotationArgs, TPrimitiveAnnotationValue, TPrimitiveBaseConfig, TPrimitiveConfig, TPrimitiveTypeArray, TPrimitiveTypeComplex, TPrimitiveTypeDef, TPrimitiveTypeFinal, TPrimitiveTypeFinalOptional, TPrimitiveTypeObject, TQueryCursorContext, TQueryLogicalOperator, TQueryOperator, TQueryScope, TSemanticToken };
|
package/dist/index.mjs
CHANGED
|
@@ -5243,6 +5243,28 @@ var AtscriptRepo = class {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
return atscript;
|
|
5245
5245
|
}
|
|
5246
|
+
/**
|
|
5247
|
+
* Drops the cached document for `id` and detaches it from its dependencies
|
|
5248
|
+
* (which also removes it from each dependency's `dependants`).
|
|
5249
|
+
*
|
|
5250
|
+
* Documents are cached forever and an imported document is read from disk
|
|
5251
|
+
* only once, so a file that changed outside the repo (a watcher, a dev
|
|
5252
|
+
* server, an editor) keeps resolving to its stale parse until it is closed.
|
|
5253
|
+
* After closing, the next `openDocument(id)` without text re-reads the file.
|
|
5254
|
+
*
|
|
5255
|
+
* Dependants are left untouched on purpose: their next `checkDoc` re-runs
|
|
5256
|
+
* `checkImport` -> `openDocument(id)`, which re-reads the file and rewires
|
|
5257
|
+
* their `dependenciesMap` to the fresh document.
|
|
5258
|
+
*
|
|
5259
|
+
* @returns `true` when a cached document was dropped, `false` when nothing
|
|
5260
|
+
* was cached under `id`.
|
|
5261
|
+
*/ closeDocument(id) {
|
|
5262
|
+
const cached = this.atscripts.get(id);
|
|
5263
|
+
if (!cached) return false;
|
|
5264
|
+
this.atscripts.delete(id);
|
|
5265
|
+
cached.then((d) => d.updateDependencies([]), () => {});
|
|
5266
|
+
return true;
|
|
5267
|
+
}
|
|
5246
5268
|
async _openDocument(id, text) {
|
|
5247
5269
|
const { manager } = await this.resolveConfig(id);
|
|
5248
5270
|
const newId = await manager.resolve(id);
|
|
@@ -5516,6 +5538,19 @@ function hasNavPropAnnotation(prop) {
|
|
|
5516
5538
|
if (!prop.annotations) return false;
|
|
5517
5539
|
return prop.annotations.some((a) => a.name === "db.rel.to" || a.name === "db.rel.from" || a.name === "db.rel.via");
|
|
5518
5540
|
}
|
|
5541
|
+
/**
|
|
5542
|
+
* Annotations that make an interface a DB entity — a table, or a managed view.
|
|
5543
|
+
* `@db.view.for` alone declares a managed view (`@db.view`, the name, is
|
|
5544
|
+
* optional), so codegen (`__flat` / `__ownProps`), the `asc db sync` inventory
|
|
5545
|
+
* and `DbSpace.get()` in `@atscript/db` all share this one rule.
|
|
5546
|
+
*/ const DB_ENTITY_ANNOTATIONS = [
|
|
5547
|
+
"db.table",
|
|
5548
|
+
"db.view",
|
|
5549
|
+
"db.view.for"
|
|
5550
|
+
];
|
|
5551
|
+
/** AST side of {@link DB_ENTITY_ANNOTATIONS}: whether a node carries a DB-entity annotation. */ function isDbEntityNode(node) {
|
|
5552
|
+
return !!node.annotations?.some((a) => DB_ENTITY_ANNOTATIONS.some((name) => name === a.name));
|
|
5553
|
+
}
|
|
5519
5554
|
function isPhantomNode(doc, def) {
|
|
5520
5555
|
if (!def) return false;
|
|
5521
5556
|
if (isPrimitive(def) && def.config.type === "phantom") return true;
|
|
@@ -5738,4 +5773,4 @@ function walkArrayElement(doc, arrayNode, prefix, parentOptional, flatMap, stack
|
|
|
5738
5773
|
}
|
|
5739
5774
|
|
|
5740
5775
|
//#endregion
|
|
5741
|
-
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
5776
|
+
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DB_ENTITY_ANNOTATIONS, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|