@platformos/platformos-graph 0.0.19 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +516 -0
- package/bin/platformos-graph +21 -81
- package/dist/cache-probes.spec.d.ts +1 -0
- package/dist/cache-probes.spec.js +62 -0
- package/dist/cache-probes.spec.js.map +1 -0
- package/dist/cli.d.ts +46 -0
- package/dist/cli.js +131 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.spec.d.ts +1 -0
- package/dist/cli.spec.js +235 -0
- package/dist/cli.spec.js.map +1 -0
- package/dist/graph/app-index-resolution.spec.d.ts +1 -0
- package/dist/graph/app-index-resolution.spec.js +167 -0
- package/dist/graph/app-index-resolution.spec.js.map +1 -0
- package/dist/graph/asset-resolution.spec.d.ts +1 -0
- package/dist/graph/asset-resolution.spec.js +64 -0
- package/dist/graph/asset-resolution.spec.js.map +1 -0
- package/dist/graph/augment.js +3 -1
- package/dist/graph/augment.js.map +1 -1
- package/dist/graph/build.d.ts +15 -2
- package/dist/graph/build.js +54 -12
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/build.spec.d.ts +1 -0
- package/dist/graph/build.spec.js +138 -0
- package/dist/graph/build.spec.js.map +1 -0
- package/dist/graph/edge-sources.d.ts +28 -0
- package/dist/graph/edge-sources.js +43 -0
- package/dist/graph/edge-sources.js.map +1 -0
- package/dist/graph/edge-sources.spec.d.ts +1 -0
- package/dist/graph/edge-sources.spec.js +125 -0
- package/dist/graph/edge-sources.spec.js.map +1 -0
- package/dist/graph/extract.spec.d.ts +1 -0
- package/dist/graph/extract.spec.js +163 -0
- package/dist/graph/extract.spec.js.map +1 -0
- package/dist/graph/module.d.ts +70 -2
- package/dist/graph/module.js +164 -29
- package/dist/graph/module.js.map +1 -1
- package/dist/graph/module.spec.d.ts +1 -0
- package/dist/graph/module.spec.js +74 -0
- package/dist/graph/module.spec.js.map +1 -0
- package/dist/graph/query.d.ts +72 -0
- package/dist/graph/query.js +140 -0
- package/dist/graph/query.js.map +1 -0
- package/dist/graph/query.spec.d.ts +1 -0
- package/dist/graph/query.spec.js +209 -0
- package/dist/graph/query.spec.js.map +1 -0
- package/dist/graph/serialize.spec.d.ts +1 -0
- package/dist/graph/serialize.spec.js +50 -0
- package/dist/graph/serialize.spec.js.map +1 -0
- package/dist/graph/structural.spec.d.ts +1 -0
- package/dist/graph/structural.spec.js +146 -0
- package/dist/graph/structural.spec.js.map +1 -0
- package/dist/graph/test-helpers.d.ts +2 -3
- package/dist/graph/test-helpers.js +5 -9
- package/dist/graph/test-helpers.js.map +1 -1
- package/dist/graph/traverse-edges.spec.d.ts +1 -0
- package/dist/graph/traverse-edges.spec.js +337 -0
- package/dist/graph/traverse-edges.spec.js.map +1 -0
- package/dist/graph/traverse.d.ts +63 -4
- package/dist/graph/traverse.js +364 -49
- package/dist/graph/traverse.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/parsers.d.ts +35 -0
- package/dist/parsers.js +72 -0
- package/dist/parsers.js.map +1 -0
- package/dist/parsers.spec.d.ts +1 -0
- package/dist/parsers.spec.js +70 -0
- package/dist/parsers.spec.js.map +1 -0
- package/dist/toSourceCode.d.ts +14 -2
- package/dist/toSourceCode.js +23 -19
- package/dist/toSourceCode.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +114 -20
- package/dist/types.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/fixtures/asset-edges/app/assets/logo.css +1 -0
- package/fixtures/asset-edges/app/assets/site/app.js +1 -0
- package/fixtures/asset-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/background-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/background-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/background-edges/app/views/partials/jobs/notify.liquid +3 -0
- package/fixtures/function-edges/app/lib/queries/list.liquid +3 -0
- package/fixtures/function-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/function-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/graphql-edges/app/graphql/blog_posts/find.graphql +10 -0
- package/fixtures/graphql-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/graphql-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/graphql-table/app/graphql/with_table.graphql +5 -0
- package/fixtures/graphql-table/app/graphql/without_table.graphql +3 -0
- package/fixtures/graphql-table/app/views/pages/index.liquid +4 -0
- package/fixtures/include-edges/app/views/pages/index.liquid +1 -0
- package/fixtures/include-edges/app/views/partials/shared/header.liquid +1 -0
- package/fixtures/layout-edges/app/views/layouts/theme.liquid +4 -0
- package/fixtures/layout-edges/app/views/pages/broken.liquid +5 -0
- package/fixtures/layout-edges/app/views/pages/index.liquid +5 -0
- package/fixtures/module-edges/app/views/pages/index.liquid +4 -0
- package/fixtures/module-edges/modules/my_module/public/lib/queries/get.liquid +3 -0
- package/fixtures/module-edges/modules/my_module/public/views/partials/card.liquid +1 -0
- package/fixtures/schema-nodes/app/schema/blog_post.yml +6 -0
- package/fixtures/schema-nodes/app/schema/no_name.yml +3 -0
- package/fixtures/schema-nodes/app/views/pages/index.liquid +1 -0
- package/fixtures/skeleton/app/assets/app.js +1 -0
- package/fixtures/skeleton/app/views/partials/child.liquid +2 -4
- package/fixtures/skeleton/app/views/partials/parent.liquid +2 -4
- package/fixtures/structural/app/views/pages/about.liquid +1 -0
- package/fixtures/structural/app/views/pages/blog/show.liquid +4 -0
- package/fixtures/structural/app/views/pages/index.liquid +6 -0
- package/fixtures/structural/app/views/pages/rich.liquid +8 -0
- package/fixtures/structural/app/views/partials/card.liquid +1 -0
- package/fixtures/structural/app/views/partials/documented.liquid +5 -0
- package/package.json +7 -5
- package/src/cli.spec.ts +271 -0
- package/src/cli.ts +167 -0
- package/src/graph/augment.ts +4 -2
- package/src/graph/build.spec.ts +888 -9
- package/src/graph/build.ts +68 -17
- package/src/graph/edge-sources.spec.ts +125 -0
- package/src/graph/edge-sources.ts +49 -0
- package/src/graph/module.spec.ts +168 -0
- package/src/graph/module.ts +167 -33
- package/src/graph/query.spec.ts +260 -0
- package/src/graph/query.ts +154 -0
- package/src/graph/serialize.spec.ts +4 -4
- package/src/graph/test-helpers.ts +5 -12
- package/src/graph/traverse.spec.ts +278 -0
- package/src/graph/traverse.ts +423 -54
- package/src/index.ts +16 -1
- package/src/parsers.spec.ts +85 -0
- package/src/parsers.ts +75 -0
- package/src/toSourceCode.ts +26 -26
- package/src/types.ts +120 -23
- package/src/utils/index.ts +1 -1
- package/bin/jsconfig.json +0 -18
- package/dist/getWebComponentMap.d.ts +0 -10
- package/dist/getWebComponentMap.js +0 -66
- package/dist/getWebComponentMap.js.map +0 -1
- package/fixtures/skeleton/assets/app.js +0 -7
- package/src/getWebComponentMap.ts +0 -81
- /package/fixtures/skeleton/{assets → app/assets}/app.css +0 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,39 +1,137 @@
|
|
|
1
|
-
import { JSONSourceCode, LiquidSourceCode, Dependencies as CheckDependencies, UriString, Reference, Location, Range, GraphQLSourceCode, YAMLSourceCode } from '@platformos/platformos-check-common';
|
|
1
|
+
import { JSONSourceCode, LiquidSourceCode, Dependencies as CheckDependencies, UriString, Reference, ReferenceKind, Location, Range, GraphQLSourceCode, YAMLSourceCode } from '@platformos/platformos-check-common';
|
|
2
|
+
import type { App, AppResolver } from '@platformos/platformos-common';
|
|
2
3
|
export interface IDependencies {
|
|
3
4
|
fs: CheckDependencies['fs'];
|
|
4
5
|
/** Optional perf improvement if you somehow have access to pre-computed source code info */
|
|
5
6
|
getSourceCode?: (uri: UriString) => Promise<FileSourceCode>;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The {@link App} whose per-type name index answers `{% render 'ui/card' %}`,
|
|
9
|
+
* `{% function … = 'commands/create' %}`, `{% graphql … = 'user/find' %}` and
|
|
10
|
+
* `layout: application` — the same object {@link IDependencies.getSourceCode} reads through
|
|
11
|
+
* when it is `appBackedGetSourceCode`.
|
|
12
|
+
*
|
|
13
|
+
* The pairing is the point: a caller that holds an App should hand it over for BOTH, so the
|
|
14
|
+
* graph reuses the lint's parses AND its index. Without it, `DocumentsLocator` falls back to a
|
|
15
|
+
* walk-only stand-in and every reference costs a `readDirectory` per candidate directory.
|
|
16
|
+
*
|
|
17
|
+
* It cannot change the ANSWER, only what it costs: `App.findOrLocate` resolves index-first and
|
|
18
|
+
* falls through to the very walk the stand-in performs. Omit it where there is genuinely no
|
|
19
|
+
* App: a build in a worker thread, a CLI, a fixture.
|
|
20
|
+
*/
|
|
21
|
+
app?: App | AppResolver;
|
|
11
22
|
}
|
|
12
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `IDependencies` with the optional PERFORMANCE seams resolved by
|
|
25
|
+
* `augmentDependencies` — `getSourceCode` always present, `app` still optional
|
|
26
|
+
* because "no app here" is a legitimate final state, not an unaugmented one.
|
|
27
|
+
*/
|
|
28
|
+
export type Dependencies = Required<Omit<IDependencies, 'app'>> & Pick<IDependencies, 'app'>;
|
|
13
29
|
export type AugmentedDependencies = Dependencies;
|
|
30
|
+
/** Options controlling what a build/traversal computes beyond the edge graph. */
|
|
31
|
+
export interface GraphBuildOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Populate each {@link LiquidModule.structural} (self-structural facts) during
|
|
34
|
+
* the build, as a by-product of the parse. OFF by default: a consumer that
|
|
35
|
+
* needs one buffer's structural facts should call `extractStructural` directly
|
|
36
|
+
* (the per-file primitive), so a full graph build — e.g. the LSP's, which never
|
|
37
|
+
* reads `structural` — does not compute a fact nothing consumes.
|
|
38
|
+
*/
|
|
39
|
+
includeStructural?: boolean;
|
|
40
|
+
}
|
|
14
41
|
export interface AppGraph {
|
|
15
42
|
rootUri: UriString;
|
|
16
43
|
entryPoints: AppModule[];
|
|
17
44
|
modules: Record<UriString, AppModule>;
|
|
18
45
|
}
|
|
19
|
-
export type AppModule = LiquidModule | AssetModule;
|
|
46
|
+
export type AppModule = LiquidModule | AssetModule | GraphQLModule | SchemaModule;
|
|
20
47
|
export type FileSourceCode = LiquidSourceCode | JSONSourceCode | GraphQLSourceCode | YAMLSourceCode | AssetSourceCode;
|
|
21
48
|
export interface SerializableGraph {
|
|
22
49
|
rootUri: UriString;
|
|
23
50
|
nodes: SerializableNode[];
|
|
24
51
|
edges: SerializableEdge[];
|
|
25
52
|
}
|
|
26
|
-
export
|
|
27
|
-
source: Location;
|
|
28
|
-
target: Location;
|
|
29
|
-
}
|
|
53
|
+
export type SerializableEdge = Reference;
|
|
30
54
|
export type SerializableNode = Pick<AppModule, 'uri' | 'type' | 'kind' | 'exists'>;
|
|
55
|
+
/**
|
|
56
|
+
* A Liquid file's own structural declarations — a by-product of the parse the
|
|
57
|
+
* graph already does, so consumers need not re-parse the file.
|
|
58
|
+
*
|
|
59
|
+
* The usage arrays are ALWAYS present (sorted, de-duplicated): an empty array
|
|
60
|
+
* means "the file uses none", since the whole AST is analyzed — never "not
|
|
61
|
+
* extracted". The routing facts (`slug`/`layout`/`method`) are optional: an
|
|
62
|
+
* absent one means "not applicable / not declared" (e.g. a partial has no slug).
|
|
63
|
+
* `doc_params` lands in a later phase and will appear here when it does.
|
|
64
|
+
*/
|
|
65
|
+
export interface ModuleStructural {
|
|
66
|
+
/** Partial names rendered via `{% render %}` / `{% include %}` (the literal target names). */
|
|
67
|
+
renders_used: string[];
|
|
68
|
+
/** Operation names invoked via `{% graphql %}` (the literal target names). */
|
|
69
|
+
graphql_queries_used: string[];
|
|
70
|
+
/** Liquid filter names used anywhere in the file. */
|
|
71
|
+
filters_used: string[];
|
|
72
|
+
/** Liquid tag names used anywhere in the file. */
|
|
73
|
+
tags_used: string[];
|
|
74
|
+
/** Translation keys referenced via the `t` / `translate` filter. */
|
|
75
|
+
translation_keys: string[];
|
|
76
|
+
/** `@param` names declared in the file's `{% doc %}` block. */
|
|
77
|
+
doc_params: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Effective URL slug: the frontmatter `slug` override if declared, else
|
|
80
|
+
* derived from the page's path. Present for page files only.
|
|
81
|
+
*/
|
|
82
|
+
slug?: string;
|
|
83
|
+
/** Declared wrapper layout (frontmatter `layout`), when declared. */
|
|
84
|
+
layout?: string;
|
|
85
|
+
/** Declared HTTP method (frontmatter `method`), when declared. */
|
|
86
|
+
method?: string;
|
|
87
|
+
}
|
|
31
88
|
export interface LiquidModule extends IAppModule<ModuleType.Liquid> {
|
|
32
89
|
kind: LiquidModuleKind;
|
|
90
|
+
/**
|
|
91
|
+
* The file's own structural declarations, populated during a full
|
|
92
|
+
* `buildAppGraph`. Absent when the file declares none of the surfaced facts.
|
|
93
|
+
*/
|
|
94
|
+
structural?: ModuleStructural;
|
|
33
95
|
}
|
|
34
96
|
export interface AssetModule extends IAppModule<ModuleType.Asset> {
|
|
35
97
|
kind: 'unused';
|
|
36
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* A `.graphql` operation file (referenced by `{% graphql op = 'name' %}`).
|
|
101
|
+
* A leaf node — GraphQL documents have no outgoing platformOS dependencies —
|
|
102
|
+
* so it is not traversed, only existence-checked (like {@link AssetModule}).
|
|
103
|
+
*/
|
|
104
|
+
export interface GraphQLModule extends IAppModule<ModuleType.GraphQL> {
|
|
105
|
+
kind: 'graphql';
|
|
106
|
+
/**
|
|
107
|
+
* The platformOS model tables this operation targets (from its `table`
|
|
108
|
+
* filters / `record_create` inputs) — every distinct table in document order.
|
|
109
|
+
* Populated during `buildAppGraph` traversal; always present (empty = the
|
|
110
|
+
* operation declares no table, or was never resolved on disk).
|
|
111
|
+
*/
|
|
112
|
+
tables: string[];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* A custom model type / schema file (`custom_model_types`/`model_schemas`/
|
|
116
|
+
* `schema` dirs — `PlatformOSFileType.Table`). A platform primitive,
|
|
117
|
+
* modeled as a neutral graph node. A leaf node — schema files have no outgoing
|
|
118
|
+
* platformOS dependencies — and not render-reachable, so it is discovered and
|
|
119
|
+
* added explicitly during a full `buildAppGraph` (never an entry point).
|
|
120
|
+
*
|
|
121
|
+
* NOTE (ADR 004): this is a neutral platform fact. The commands/queries
|
|
122
|
+
* convention and resource/CRUD completeness that build ON schemas are NOT
|
|
123
|
+
* modeled here — they live in the convention overlay.
|
|
124
|
+
*/
|
|
125
|
+
export interface SchemaModule extends IAppModule<ModuleType.Schema> {
|
|
126
|
+
kind: 'schema';
|
|
127
|
+
/**
|
|
128
|
+
* The model table name (the schema's top-level `name:`), when declared. A
|
|
129
|
+
* schema declares exactly one, so this is a single value (unlike a GraphQL
|
|
130
|
+
* op's {@link GraphQLModule.tables}) that a consumer can join against. Absent
|
|
131
|
+
* when the file declares no `name:` or could not be parsed.
|
|
132
|
+
*/
|
|
133
|
+
table?: string;
|
|
134
|
+
}
|
|
37
135
|
export interface IAppModule<T extends ModuleType> {
|
|
38
136
|
/** Used as a discriminant in the AppModule union */
|
|
39
137
|
type: T;
|
|
@@ -60,7 +158,9 @@ export interface IAppModule<T extends ModuleType> {
|
|
|
60
158
|
}
|
|
61
159
|
export declare const enum ModuleType {
|
|
62
160
|
Liquid = "Liquid",
|
|
63
|
-
Asset = "Asset"
|
|
161
|
+
Asset = "Asset",
|
|
162
|
+
GraphQL = "GraphQL",
|
|
163
|
+
Schema = "Schema"
|
|
64
164
|
}
|
|
65
165
|
export declare const enum LiquidModuleKind {
|
|
66
166
|
/** app/views/layouts/*.liquid files */
|
|
@@ -77,11 +177,5 @@ export interface AssetSourceCode {
|
|
|
77
177
|
source: string;
|
|
78
178
|
ast: any | Error;
|
|
79
179
|
}
|
|
80
|
-
export { Reference, Range, Location };
|
|
180
|
+
export { Reference, ReferenceKind, Range, Location };
|
|
81
181
|
export type Void = void | Void[];
|
|
82
|
-
export type WebComponentMap = Map<WebComponentName, WebComponentDefinition>;
|
|
83
|
-
export type WebComponentName = string;
|
|
84
|
-
export type WebComponentDefinition = {
|
|
85
|
-
assetName: string;
|
|
86
|
-
range: [number, number];
|
|
87
|
-
};
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAqNa,QAAA,gCAAgC,GAAG;IAC9C,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;CACN,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UriString } from '@platformos/platformos-check-common';
|
|
2
2
|
import { AbstractFileSystem } from '@platformos/platformos-common';
|
|
3
3
|
export declare function unique<T>(array: T[]): T[];
|
|
4
|
-
export declare function assertNever(module: never):
|
|
4
|
+
export declare function assertNever(module: never): never;
|
|
5
5
|
export declare const identity: <T>(x: T) => T;
|
|
6
6
|
export declare function isString(x: unknown): x is string;
|
|
7
7
|
export declare function extname(uri: UriString): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
body { color: red; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("app");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{% include 'shared/header' %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<header>site</header>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<article>card</article>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>home</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Skeleton app bundle (asset reference target).
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{% doc %}
|
|
2
|
-
Parent partial that renders the
|
|
2
|
+
Parent partial that renders the child partial.
|
|
3
3
|
|
|
4
4
|
@param {string} children
|
|
5
5
|
{% enddoc %}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
{% render "child", children: children %}
|
|
9
|
-
</parent-element>
|
|
7
|
+
{% render "child", children: children %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h1>about</h1>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="card">{{ title }}</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/platformos-graph",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "platformOS App Graph as a data structure",
|
|
5
5
|
"author": "platformOS",
|
|
6
6
|
"homepage": "https://github.com/Platform-OS/platformos-tools/tree/master/packages/platformos-graph#readme",
|
|
@@ -29,13 +29,15 @@
|
|
|
29
29
|
"type-check": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@platformos/liquid-html-parser": "^0.0
|
|
33
|
-
"@platformos/platformos-check-common": "0.0
|
|
32
|
+
"@platformos/liquid-html-parser": "^0.1.0",
|
|
33
|
+
"@platformos/platformos-check-common": "1.0.0",
|
|
34
|
+
"@platformos/platformos-common": "0.1.0",
|
|
34
35
|
"acorn": "^8.16.0",
|
|
35
|
-
"
|
|
36
|
+
"js-yaml": "^4.1.1",
|
|
36
37
|
"vscode-uri": "^3.1.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@platformos/platformos-check-node": "0.0
|
|
40
|
+
"@platformos/platformos-check-node": "1.0.0",
|
|
41
|
+
"@types/js-yaml": "^4.0.9"
|
|
40
42
|
}
|
|
41
43
|
}
|