@platformos/platformos-common 0.0.10 → 0.0.12
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 +35 -0
- package/CLAUDE.md +70 -0
- package/dist/documents-locator/DocumentsLocator.d.ts +35 -2
- package/dist/documents-locator/DocumentsLocator.js +126 -1
- package/dist/documents-locator/DocumentsLocator.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/path-utils.d.ts +59 -15
- package/dist/path-utils.js +100 -28
- package/dist/path-utils.js.map +1 -1
- package/dist/route-table/RouteTable.d.ts +45 -0
- package/dist/route-table/RouteTable.js +384 -0
- package/dist/route-table/RouteTable.js.map +1 -0
- package/dist/route-table/index.d.ts +5 -0
- package/dist/route-table/index.js +13 -0
- package/dist/route-table/index.js.map +1 -0
- package/dist/route-table/parseSlug.d.ts +31 -0
- package/dist/route-table/parseSlug.js +124 -0
- package/dist/route-table/parseSlug.js.map +1 -0
- package/dist/route-table/slugFromFilePath.d.ts +23 -0
- package/dist/route-table/slugFromFilePath.js +81 -0
- package/dist/route-table/slugFromFilePath.js.map +1 -0
- package/dist/route-table/types.d.ts +30 -0
- package/dist/route-table/types.js +3 -0
- package/dist/route-table/types.js.map +1 -0
- package/dist/translation-provider/TranslationProvider.d.ts +1 -1
- package/dist/translation-provider/TranslationProvider.js +2 -2
- package/dist/translation-provider/TranslationProvider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/documents-locator/DocumentsLocator.spec.ts +299 -5
- package/src/documents-locator/DocumentsLocator.ts +144 -1
- package/src/index.ts +1 -0
- package/src/path-utils.spec.ts +320 -33
- package/src/path-utils.ts +103 -28
- package/src/route-table/RouteTable.spec.ts +708 -0
- package/src/route-table/RouteTable.ts +437 -0
- package/src/route-table/index.ts +5 -0
- package/src/route-table/parseSlug.spec.ts +177 -0
- package/src/route-table/parseSlug.ts +136 -0
- package/src/route-table/slugFromFilePath.spec.ts +84 -0
- package/src/route-table/slugFromFilePath.ts +84 -0
- package/src/route-table/types.ts +25 -0
- package/src/translation-provider/TranslationProvider.ts +4 -2
package/dist/path-utils.js
CHANGED
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
* - getFileType() classifies any URI to a PlatformOSFileType
|
|
10
10
|
* - isPage(), isLayout(), isPartial() etc. are convenience wrappers around getFileType()
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* /
|
|
14
|
-
*
|
|
15
|
-
* (
|
|
12
|
+
* Source of truth: app/services/app_builder/services/converters_config.rb and
|
|
13
|
+
* app/models/concerns/deployable.rb in the platformOS server codebase.
|
|
14
|
+
*
|
|
15
|
+
* DIR_PREFIX (Ruby): ^/?((marketplace_builder|app)/|modules/(.+)(private|public)/)?
|
|
16
|
+
* This means files can live under:
|
|
17
|
+
* - app/{dir}/
|
|
18
|
+
* - marketplace_builder/{dir}/ (legacy alias for app/)
|
|
19
|
+
* - modules/{name}/(public|private)/{dir}/
|
|
20
|
+
* - app/modules/{name}/(public|private)/{dir}/
|
|
16
21
|
*/
|
|
17
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
23
|
exports.FILE_TYPE_DIRS = exports.PlatformOSFileType = void 0;
|
|
@@ -20,6 +25,7 @@ exports.getFileType = getFileType;
|
|
|
20
25
|
exports.getAppPaths = getAppPaths;
|
|
21
26
|
exports.getModulePaths = getModulePaths;
|
|
22
27
|
exports.isKnownLiquidFile = isKnownLiquidFile;
|
|
28
|
+
exports.isKnownGraphQLFile = isKnownGraphQLFile;
|
|
23
29
|
exports.isPartial = isPartial;
|
|
24
30
|
exports.isPage = isPage;
|
|
25
31
|
exports.isLayout = isLayout;
|
|
@@ -28,50 +34,98 @@ exports.isEmail = isEmail;
|
|
|
28
34
|
exports.isApiCall = isApiCall;
|
|
29
35
|
exports.isSms = isSms;
|
|
30
36
|
exports.isMigration = isMigration;
|
|
37
|
+
exports.isFormConfiguration = isFormConfiguration;
|
|
31
38
|
/**
|
|
32
|
-
* File types that exist in a platformOS app, each
|
|
33
|
-
*
|
|
39
|
+
* File types that exist in a platformOS app, each corresponding to a server-side
|
|
40
|
+
* converter that processes the file on deploy.
|
|
41
|
+
*
|
|
42
|
+
* Liquid types: Page, Layout, Partial, Authorization, Email, ApiCall, Sms, Migration, FormConfiguration
|
|
43
|
+
* YAML types: CustomModelType, InstanceProfileType, TransactableType, Translation
|
|
44
|
+
* GraphQL types: GraphQL
|
|
45
|
+
* Binary/other: Asset
|
|
34
46
|
*/
|
|
35
47
|
var PlatformOSFileType;
|
|
36
48
|
(function (PlatformOSFileType) {
|
|
49
|
+
// ── Liquid ──────────────────────────────────────────────────────────────────
|
|
50
|
+
/** views/pages/ or pages/ → PageConverter */
|
|
37
51
|
PlatformOSFileType["Page"] = "Page";
|
|
52
|
+
/** views/layouts/ → LiquidViewConverter (layouts) */
|
|
38
53
|
PlatformOSFileType["Layout"] = "Layout";
|
|
54
|
+
/** views/partials/ or lib/ → LiquidViewConverter (partials) */
|
|
39
55
|
PlatformOSFileType["Partial"] = "Partial";
|
|
56
|
+
/** authorization_policies/ → AuthorizationPolicyConverter */
|
|
40
57
|
PlatformOSFileType["Authorization"] = "Authorization";
|
|
58
|
+
/** emails/ or notifications/email_notifications/ → EmailNotificationConverter */
|
|
41
59
|
PlatformOSFileType["Email"] = "Email";
|
|
60
|
+
/** api_calls/ or notifications/api_call_notifications/ → ApiCallNotificationConverter */
|
|
42
61
|
PlatformOSFileType["ApiCall"] = "ApiCall";
|
|
62
|
+
/** smses/ or notifications/sms_notifications/ → SmsNotificationConverter */
|
|
43
63
|
PlatformOSFileType["Sms"] = "Sms";
|
|
64
|
+
/** migrations/ → MigrationConverter */
|
|
44
65
|
PlatformOSFileType["Migration"] = "Migration";
|
|
66
|
+
/** form_configurations/ or forms/ → FormConfigurationConverter */
|
|
67
|
+
PlatformOSFileType["FormConfiguration"] = "FormConfiguration";
|
|
68
|
+
// ── YAML ────────────────────────────────────────────────────────────────────
|
|
69
|
+
/** custom_model_types/, model_schemas/, or schema/ → CustomModelTypeConverter */
|
|
70
|
+
PlatformOSFileType["CustomModelType"] = "CustomModelType";
|
|
71
|
+
/** instance_profile_types/, user_profile_types/, or user_profile_schemas/ → InstanceProfileTypeConverter */
|
|
72
|
+
PlatformOSFileType["InstanceProfileType"] = "InstanceProfileType";
|
|
73
|
+
/** transactable_types/ → TransactableTypeConverter */
|
|
74
|
+
PlatformOSFileType["TransactableType"] = "TransactableType";
|
|
75
|
+
/** translations/ → TranslationConverter */
|
|
76
|
+
PlatformOSFileType["Translation"] = "Translation";
|
|
77
|
+
// ── GraphQL ─────────────────────────────────────────────────────────────────
|
|
78
|
+
/** graphql/ or graph_queries/ → GraphQueryConverter */
|
|
45
79
|
PlatformOSFileType["GraphQL"] = "GraphQL";
|
|
80
|
+
// ── Binary/other ────────────────────────────────────────────────────────────
|
|
81
|
+
/** assets/ → AssetConverter */
|
|
46
82
|
PlatformOSFileType["Asset"] = "Asset";
|
|
47
83
|
})(PlatformOSFileType || (exports.PlatformOSFileType = PlatformOSFileType = {}));
|
|
48
84
|
/**
|
|
49
85
|
* The single source of truth for the platformOS directory structure.
|
|
50
86
|
*
|
|
51
87
|
* Maps each file type to its canonical directory name(s) relative to:
|
|
52
|
-
* - the app root: app/{dir}/
|
|
88
|
+
* - the app root: (app|marketplace_builder)/{dir}/
|
|
53
89
|
* - a module access level: modules/{name}/(public|private)/{dir}/
|
|
54
90
|
* - a nested module access level: app/modules/{name}/(public|private)/{dir}/
|
|
55
91
|
*
|
|
92
|
+
* Multiple dirs per type represent canonical + legacy aliases from the server
|
|
93
|
+
* converters_config.rb FULL_PHYSICAL_PATH regexes.
|
|
94
|
+
*
|
|
56
95
|
* Types with multiple dirs (e.g. Partial) will match any of their dirs.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
96
|
+
* Order within each array doesn't matter for matching. Across types,
|
|
97
|
+
* exact segment matching prevents false positives between overlapping paths
|
|
98
|
+
* (e.g. app/lib/smses/ → Partial, not Sms).
|
|
59
99
|
*/
|
|
60
100
|
exports.FILE_TYPE_DIRS = {
|
|
61
|
-
|
|
101
|
+
// Liquid
|
|
102
|
+
[PlatformOSFileType.Page]: ['views/pages', 'pages'],
|
|
62
103
|
[PlatformOSFileType.Layout]: ['views/layouts'],
|
|
63
104
|
[PlatformOSFileType.Partial]: ['views/partials', 'lib'],
|
|
64
105
|
[PlatformOSFileType.Authorization]: ['authorization_policies'],
|
|
65
|
-
[PlatformOSFileType.Email]: ['emails'],
|
|
66
|
-
[PlatformOSFileType.ApiCall]: ['api_calls'],
|
|
67
|
-
[PlatformOSFileType.Sms]: ['smses'],
|
|
106
|
+
[PlatformOSFileType.Email]: ['emails', 'notifications/email_notifications'],
|
|
107
|
+
[PlatformOSFileType.ApiCall]: ['api_calls', 'notifications/api_call_notifications'],
|
|
108
|
+
[PlatformOSFileType.Sms]: ['smses', 'notifications/sms_notifications'],
|
|
68
109
|
[PlatformOSFileType.Migration]: ['migrations'],
|
|
69
|
-
[PlatformOSFileType.
|
|
110
|
+
[PlatformOSFileType.FormConfiguration]: ['form_configurations', 'forms'],
|
|
111
|
+
// YAML
|
|
112
|
+
[PlatformOSFileType.CustomModelType]: ['custom_model_types', 'model_schemas', 'schema'],
|
|
113
|
+
[PlatformOSFileType.InstanceProfileType]: [
|
|
114
|
+
'instance_profile_types',
|
|
115
|
+
'user_profile_types',
|
|
116
|
+
'user_profile_schemas',
|
|
117
|
+
],
|
|
118
|
+
[PlatformOSFileType.TransactableType]: ['transactable_types'],
|
|
119
|
+
[PlatformOSFileType.Translation]: ['translations'],
|
|
120
|
+
// GraphQL
|
|
121
|
+
[PlatformOSFileType.GraphQL]: ['graphql', 'graph_queries'],
|
|
122
|
+
// Asset
|
|
70
123
|
[PlatformOSFileType.Asset]: ['assets'],
|
|
71
124
|
};
|
|
72
125
|
/**
|
|
73
|
-
* Liquid-containing file types. GraphQL and
|
|
74
|
-
* don't contain Liquid code and should not be passed to the
|
|
126
|
+
* Liquid-containing file types. GraphQL, Asset, and YAML types are excluded
|
|
127
|
+
* because they don't contain Liquid code and should not be passed to the
|
|
128
|
+
* Liquid linter.
|
|
75
129
|
*/
|
|
76
130
|
const LIQUID_FILE_TYPES = new Set([
|
|
77
131
|
PlatformOSFileType.Page,
|
|
@@ -82,31 +136,39 @@ const LIQUID_FILE_TYPES = new Set([
|
|
|
82
136
|
PlatformOSFileType.ApiCall,
|
|
83
137
|
PlatformOSFileType.Sms,
|
|
84
138
|
PlatformOSFileType.Migration,
|
|
139
|
+
PlatformOSFileType.FormConfiguration,
|
|
85
140
|
]);
|
|
86
141
|
/**
|
|
87
142
|
* Pre-compiled regex per file type, derived entirely from FILE_TYPE_DIRS.
|
|
88
143
|
*
|
|
89
|
-
* For each canonical dir,
|
|
90
|
-
* /app/{dir}/
|
|
91
|
-
* /(public|private)/{dir}/
|
|
92
|
-
*
|
|
93
|
-
*
|
|
144
|
+
* For each canonical dir, three pattern alternatives are generated:
|
|
145
|
+
* /(app|marketplace_builder)/{dir}/ — direct app-level path (modern + legacy root)
|
|
146
|
+
* /(public|private)/{dir}/ — module path, covers both:
|
|
147
|
+
* modules/{name}/(public|private)/{dir}/
|
|
148
|
+
* app/modules/{name}/(public|private)/{dir}/
|
|
94
149
|
*
|
|
95
150
|
* Exact path segment matching prevents false positives:
|
|
96
151
|
* /app/lib/smses/file.liquid → matches /app/lib/ → Partial (NOT Sms)
|
|
97
152
|
* /app/smses/file.liquid → matches /app/smses/ → Sms (NOT Partial)
|
|
98
153
|
*/
|
|
99
154
|
const TYPE_MATCHERS = new Map(Object.entries(exports.FILE_TYPE_DIRS).map(([type, dirs]) => {
|
|
100
|
-
const alternatives = dirs.flatMap((dir) => [
|
|
155
|
+
const alternatives = dirs.flatMap((dir) => [
|
|
156
|
+
`/(app|marketplace_builder)/${dir}/`,
|
|
157
|
+
`/(public|private)/${dir}/`,
|
|
158
|
+
]);
|
|
101
159
|
return [type, new RegExp(alternatives.join('|'))];
|
|
102
160
|
}));
|
|
103
161
|
/**
|
|
104
162
|
* Returns the PlatformOSFileType for the given URI, or undefined if the URI
|
|
105
163
|
* does not belong to any recognized platformOS directory.
|
|
106
164
|
*
|
|
165
|
+
* Supports both modern (app/) and legacy (marketplace_builder/) app roots,
|
|
166
|
+
* as well as module paths (modules/{name}/public|private/).
|
|
167
|
+
*
|
|
107
168
|
* @example
|
|
108
|
-
* getFileType('file:///root/app/lib/smses/notify.liquid')
|
|
109
|
-
* getFileType('file:///root/app/smses/notify.liquid')
|
|
169
|
+
* getFileType('file:///root/app/lib/smses/notify.liquid') // → Partial
|
|
170
|
+
* getFileType('file:///root/app/smses/notify.liquid') // → Sms
|
|
171
|
+
* getFileType('file:///root/marketplace_builder/views/pages/home.liquid') // → Page
|
|
110
172
|
* getFileType('file:///root/modules/core/generators/templates/lib/create.liquid') // → undefined
|
|
111
173
|
*/
|
|
112
174
|
function getFileType(uri) {
|
|
@@ -118,10 +180,11 @@ function getFileType(uri) {
|
|
|
118
180
|
}
|
|
119
181
|
/**
|
|
120
182
|
* Returns app-level search paths for a file type (relative to project root).
|
|
183
|
+
* Uses the modern `app/` root (not the legacy `marketplace_builder/` alias).
|
|
121
184
|
*
|
|
122
185
|
* @example
|
|
123
186
|
* getAppPaths(PlatformOSFileType.Partial) // → ['app/views/partials', 'app/lib']
|
|
124
|
-
* getAppPaths(PlatformOSFileType.GraphQL) // → ['app/graphql']
|
|
187
|
+
* getAppPaths(PlatformOSFileType.GraphQL) // → ['app/graphql', 'app/graph_queries']
|
|
125
188
|
*/
|
|
126
189
|
function getAppPaths(type) {
|
|
127
190
|
return exports.FILE_TYPE_DIRS[type].map((dir) => `app/${dir}`);
|
|
@@ -138,9 +201,7 @@ function getAppPaths(type) {
|
|
|
138
201
|
* 'modules/core/public/views/partials',
|
|
139
202
|
* 'modules/core/private/views/partials',
|
|
140
203
|
* 'app/modules/core/public/lib',
|
|
141
|
-
*
|
|
142
|
-
* 'modules/core/public/lib',
|
|
143
|
-
* 'modules/core/private/lib',
|
|
204
|
+
* ...
|
|
144
205
|
* ]
|
|
145
206
|
*/
|
|
146
207
|
function getModulePaths(type, moduleName) {
|
|
@@ -160,6 +221,14 @@ function isKnownLiquidFile(uri) {
|
|
|
160
221
|
const type = getFileType(uri);
|
|
161
222
|
return type !== undefined && LIQUID_FILE_TYPES.has(type);
|
|
162
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Returns true if the URI belongs to a recognized platformOS GraphQL directory
|
|
226
|
+
* and should be linted. Files outside known directories (e.g. generator
|
|
227
|
+
* templates, schema files, ERB templates) return false and are excluded.
|
|
228
|
+
*/
|
|
229
|
+
function isKnownGraphQLFile(uri) {
|
|
230
|
+
return getFileType(uri) === PlatformOSFileType.GraphQL;
|
|
231
|
+
}
|
|
163
232
|
function isPartial(uri) {
|
|
164
233
|
return getFileType(uri) === PlatformOSFileType.Partial;
|
|
165
234
|
}
|
|
@@ -184,4 +253,7 @@ function isSms(uri) {
|
|
|
184
253
|
function isMigration(uri) {
|
|
185
254
|
return getFileType(uri) === PlatformOSFileType.Migration;
|
|
186
255
|
}
|
|
256
|
+
function isFormConfiguration(uri) {
|
|
257
|
+
return getFileType(uri) === PlatformOSFileType.FormConfiguration;
|
|
258
|
+
}
|
|
187
259
|
//# sourceMappingURL=path-utils.js.map
|
package/dist/path-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAsJH,kCAKC;AAUD,kCAEC;AAiBD,wCAOC;AAOD,8CAGC;AAOD,gDAEC;AAED,8BAEC;AAED,wBAEC;AAED,4BAEC;AAED,0CAEC;AAED,0BAEC;AAED,8BAEC;AAED,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
|
3
|
+
import { RouteEntry } from './types';
|
|
4
|
+
export declare class RouteTable {
|
|
5
|
+
private fs;
|
|
6
|
+
private routes;
|
|
7
|
+
private _built;
|
|
8
|
+
constructor(fs: AbstractFileSystem);
|
|
9
|
+
/** Returns true if build() has completed at least once. */
|
|
10
|
+
isBuilt(): boolean;
|
|
11
|
+
build(rootUri: URI): Promise<void>;
|
|
12
|
+
updateFile(uri: string, content: string): void;
|
|
13
|
+
removeFile(uri: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Find all routes matching a URL pattern and optional method.
|
|
16
|
+
* The pattern can contain `:_liquid_` segments for Liquid interpolations.
|
|
17
|
+
* Results are sorted by precedence (highest priority first = lowest number).
|
|
18
|
+
*
|
|
19
|
+
* A known format extension on the last segment (e.g., `/api/data.json`)
|
|
20
|
+
* is stripped and used to filter routes by format. When no format extension
|
|
21
|
+
* is present (e.g., `/about`), only `html` routes match — following the
|
|
22
|
+
* platformOS/Rails convention where HTML is the default format and non-HTML
|
|
23
|
+
* formats require an explicit extension or Accept header.
|
|
24
|
+
*/
|
|
25
|
+
match(urlPattern: string, method?: string): RouteEntry[];
|
|
26
|
+
hasMatch(urlPattern: string, method?: string): boolean;
|
|
27
|
+
/** Returns the total number of route entries (including index aliases). */
|
|
28
|
+
routeCount(): number;
|
|
29
|
+
allRoutes(): RouteEntry[];
|
|
30
|
+
private matchEntry;
|
|
31
|
+
/**
|
|
32
|
+
* Try optional groups left-to-right greedily — matching Rails' ActionDispatch::Journey
|
|
33
|
+
* semantics. Each group is tried in order; if it matches, its segments are consumed
|
|
34
|
+
* and the next group is attempted. If it doesn't match, it's skipped (optional).
|
|
35
|
+
*
|
|
36
|
+
* This greedy approach is correct because the platformOS backend converts slugs like
|
|
37
|
+
* `search(/:country)(/:city)` into Journey path strings and Journey matches
|
|
38
|
+
* left-to-right without backtracking.
|
|
39
|
+
*/
|
|
40
|
+
private matchOptionalGroups;
|
|
41
|
+
private addPageFromContent;
|
|
42
|
+
private discoverPageFiles;
|
|
43
|
+
private discoverModuleNames;
|
|
44
|
+
private walkDirectory;
|
|
45
|
+
}
|