objectstack-vscode 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/.turbo/turbo-build.log +4 -0
- package/LICENSE +202 -0
- package/README.md +81 -0
- package/dist/extension.d.ts +3 -0
- package/dist/extension.js +205 -0
- package/dist/extension.js.map +1 -0
- package/language-configuration.json +19 -0
- package/package.json +64 -0
- package/snippets/objectstack.json +168 -0
- package/src/extension.ts +226 -0
- package/tsconfig.json +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute
|
|
108
|
+
must include a readable copy of the attribution notices
|
|
109
|
+
contained within such NOTICE file, excluding those notices
|
|
110
|
+
that do not pertain to any part of the Derivative Works,
|
|
111
|
+
in at least one of the following places: within a NOTICE
|
|
112
|
+
text file distributed as part of the Derivative Works; within
|
|
113
|
+
the Source form or documentation, if provided along with
|
|
114
|
+
the Derivative Works; or, within a display generated by the
|
|
115
|
+
Derivative Works, if and wherever such third-party notices
|
|
116
|
+
normally appear. The contents of the NOTICE file are for
|
|
117
|
+
informational purposes only and do not modify the License.
|
|
118
|
+
You may add Your own attribution notices within Derivative
|
|
119
|
+
Works that You distribute, alongside or as an addendum to
|
|
120
|
+
the NOTICE text from the Work, provided that such additional
|
|
121
|
+
attribution notices cannot be construed as modifying the
|
|
122
|
+
License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 ObjectStack
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ObjectStack for Visual Studio Code
|
|
2
|
+
|
|
3
|
+
> Autocomplete, validation, and inline diagnostics for ObjectStack Protocol files.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Snippets** — Quickly scaffold objects, fields, views, flows, agents, and full `defineStack` configs with `os-` prefixed snippets.
|
|
8
|
+
- **Hover Documentation** — Hover over `defineStack`, `defineView`, field types (`text`, `lookup`, `select`, etc.) to see inline descriptions.
|
|
9
|
+
- **Diagnostics** — Real-time warnings for common mistakes:
|
|
10
|
+
- Missing `manifest` in `defineStack()`
|
|
11
|
+
- camelCase names that should be `snake_case`
|
|
12
|
+
- **Config File Watching** — Automatically re-validates when `objectstack.config.ts` changes.
|
|
13
|
+
- **JSON Schema Validation** — Validates `objectstack.json` files against the bundled schema.
|
|
14
|
+
- **Quick Fix Stubs** — Code action provider for quick fixes (add missing label, convert to snake_case).
|
|
15
|
+
|
|
16
|
+
## Snippets
|
|
17
|
+
|
|
18
|
+
| Prefix | Description |
|
|
19
|
+
|--------|-------------|
|
|
20
|
+
| `os-object` | Define a new business object |
|
|
21
|
+
| `os-field-text` | Add a text field |
|
|
22
|
+
| `os-field-select` | Add a select (picklist) field |
|
|
23
|
+
| `os-field-lookup` | Add a lookup (reference) field |
|
|
24
|
+
| `os-view-grid` | Define a grid list view |
|
|
25
|
+
| `os-flow` | Define an automation flow |
|
|
26
|
+
| `os-stack` | Full `defineStack` boilerplate |
|
|
27
|
+
| `os-agent` | Define an AI agent |
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### From Source
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd packages/vscode-objectstack
|
|
35
|
+
npm install
|
|
36
|
+
npm run build
|
|
37
|
+
npm run package
|
|
38
|
+
# Install the generated .vsix file in VSCode
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### From Marketplace (Coming Soon)
|
|
42
|
+
|
|
43
|
+
Search for "ObjectStack" in the VSCode Extensions marketplace.
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
1. Open a project containing `objectstack.config.ts`
|
|
48
|
+
2. The extension activates automatically for `.object.ts`, `.view.ts`, and `objectstack.config.ts` files
|
|
49
|
+
3. Start typing `os-` to see available snippets
|
|
50
|
+
4. Hover over ObjectStack keywords for inline documentation
|
|
51
|
+
|
|
52
|
+
## Supported File Types
|
|
53
|
+
|
|
54
|
+
| Pattern | Description |
|
|
55
|
+
|---------|-------------|
|
|
56
|
+
| `*.object.ts` | Business object definitions |
|
|
57
|
+
| `*.view.ts` | View configurations (list, form, kanban) |
|
|
58
|
+
| `objectstack.config.ts` | Stack configuration file |
|
|
59
|
+
| `objectstack.json` | JSON configuration (with schema validation) |
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Build the extension
|
|
65
|
+
npm run build
|
|
66
|
+
|
|
67
|
+
# Watch for changes
|
|
68
|
+
npm run watch
|
|
69
|
+
|
|
70
|
+
# Package as .vsix
|
|
71
|
+
npm run package
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Requirements
|
|
75
|
+
|
|
76
|
+
- VSCode 1.85.0 or later
|
|
77
|
+
- TypeScript project using `@objectstack/spec`
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
Apache-2.0 — see [LICENSE](../../LICENSE) for details.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.activate = activate;
|
|
38
|
+
exports.deactivate = deactivate;
|
|
39
|
+
const vscode = __importStar(require("vscode"));
|
|
40
|
+
/** Well-known ObjectStack field types for hover documentation */
|
|
41
|
+
const FIELD_TYPE_DOCS = {
|
|
42
|
+
text: 'Single-line text field (max 255 chars by default)',
|
|
43
|
+
textarea: 'Multi-line text area for longer content',
|
|
44
|
+
richtext: 'Rich text editor with HTML formatting',
|
|
45
|
+
number: 'Decimal number with configurable precision',
|
|
46
|
+
integer: 'Whole number without decimals',
|
|
47
|
+
currency: 'Monetary value with currency code',
|
|
48
|
+
boolean: 'True/false toggle',
|
|
49
|
+
date: 'Calendar date (no time)',
|
|
50
|
+
datetime: 'Date with time and timezone',
|
|
51
|
+
select: 'Single-choice picklist (requires `options`)',
|
|
52
|
+
multiselect: 'Multi-choice picklist (requires `options`)',
|
|
53
|
+
lookup: 'Reference to another object (requires `reference`)',
|
|
54
|
+
master_detail: 'Parent-child relationship with cascade delete',
|
|
55
|
+
formula: 'Computed field using expressions',
|
|
56
|
+
email: 'Email address with validation',
|
|
57
|
+
phone: 'Phone number',
|
|
58
|
+
url: 'URL with protocol validation',
|
|
59
|
+
image: 'Image file reference',
|
|
60
|
+
file: 'File attachment reference',
|
|
61
|
+
json: 'Arbitrary JSON data',
|
|
62
|
+
uuid: 'Universally unique identifier',
|
|
63
|
+
slug: 'URL-friendly identifier (auto-generated from name)',
|
|
64
|
+
rating: 'Numeric star rating',
|
|
65
|
+
color: 'Hex color value (#RRGGBB)',
|
|
66
|
+
vector: 'Numeric vector for AI embeddings and similarity search',
|
|
67
|
+
encrypted: 'Encrypted at rest — displayed masked in UI',
|
|
68
|
+
autonumber: 'Auto-incrementing display number',
|
|
69
|
+
geo_point: 'Geographic coordinates (lat/lng)',
|
|
70
|
+
};
|
|
71
|
+
/** ObjectStack schema keywords for hover tooltips */
|
|
72
|
+
const SCHEMA_DOCS = {
|
|
73
|
+
defineStack: 'Define an ObjectStack project or plugin. Validates against ObjectStackDefinitionSchema.',
|
|
74
|
+
defineView: 'Type-safe helper to define a list or form view for an object.',
|
|
75
|
+
defineApp: 'Type-safe helper to define an application with navigation.',
|
|
76
|
+
defineFlow: 'Type-safe helper to define an automation flow.',
|
|
77
|
+
defineAgent: 'Type-safe helper to define an AI agent with tools and instructions.',
|
|
78
|
+
manifest: 'Project package configuration — name, version, label, and metadata.',
|
|
79
|
+
objects: 'Business object definitions with fields, validation, and relationships.',
|
|
80
|
+
views: 'List and form view configurations for object data display.',
|
|
81
|
+
flows: 'Automation flows — screen flows, auto-launched, or scheduled.',
|
|
82
|
+
agents: 'AI agent definitions with model config, tools, and instructions.',
|
|
83
|
+
actions: 'Button actions, batch operations, and URL redirects.',
|
|
84
|
+
dashboards: 'Analytics dashboard layouts with widget grids.',
|
|
85
|
+
permissions: 'Permission sets defining CRUD access per object and field.',
|
|
86
|
+
roles: 'User role hierarchy for access control.',
|
|
87
|
+
plugins: 'External plugins to load into the stack.',
|
|
88
|
+
ownership: "Record ownership model: 'own' (creator-owned) or 'shared'.",
|
|
89
|
+
objectName: 'Snake_case reference to a business object (e.g. project_task).',
|
|
90
|
+
};
|
|
91
|
+
let diagnosticCollection;
|
|
92
|
+
function activate(context) {
|
|
93
|
+
diagnosticCollection = vscode.languages.createDiagnosticCollection('objectstack');
|
|
94
|
+
context.subscriptions.push(diagnosticCollection);
|
|
95
|
+
// Watch for objectstack.config.ts changes
|
|
96
|
+
const configWatcher = vscode.workspace.createFileSystemWatcher('**/objectstack.config.ts');
|
|
97
|
+
configWatcher.onDidChange((uri) => {
|
|
98
|
+
validateConfigFile(uri);
|
|
99
|
+
});
|
|
100
|
+
configWatcher.onDidCreate((uri) => {
|
|
101
|
+
validateConfigFile(uri);
|
|
102
|
+
});
|
|
103
|
+
context.subscriptions.push(configWatcher);
|
|
104
|
+
// Register hover provider for TypeScript files
|
|
105
|
+
const hoverProvider = vscode.languages.registerHoverProvider([
|
|
106
|
+
{ scheme: 'file', pattern: '**/*.object.ts' },
|
|
107
|
+
{ scheme: 'file', pattern: '**/*.view.ts' },
|
|
108
|
+
{ scheme: 'file', pattern: '**/objectstack.config.ts' },
|
|
109
|
+
{ scheme: 'file', language: 'typescript' },
|
|
110
|
+
], {
|
|
111
|
+
provideHover(document, position) {
|
|
112
|
+
const range = document.getWordRangeAtPosition(position);
|
|
113
|
+
if (!range)
|
|
114
|
+
return undefined;
|
|
115
|
+
const word = document.getText(range);
|
|
116
|
+
// Check schema-level keywords
|
|
117
|
+
if (SCHEMA_DOCS[word]) {
|
|
118
|
+
return new vscode.Hover(new vscode.MarkdownString(`**ObjectStack** — \`${word}\`\n\n${SCHEMA_DOCS[word]}`));
|
|
119
|
+
}
|
|
120
|
+
// Check field type values (e.g. type: 'text')
|
|
121
|
+
const line = document.lineAt(position.line).text;
|
|
122
|
+
const typeMatch = line.match(/type:\s*['"](\w+)['"]/);
|
|
123
|
+
if (typeMatch && FIELD_TYPE_DOCS[typeMatch[1]]) {
|
|
124
|
+
const fieldType = typeMatch[1];
|
|
125
|
+
if (word === fieldType || word === 'type') {
|
|
126
|
+
return new vscode.Hover(new vscode.MarkdownString(`**ObjectStack Field Type** — \`${fieldType}\`\n\n${FIELD_TYPE_DOCS[fieldType]}`));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
context.subscriptions.push(hoverProvider);
|
|
133
|
+
// Register code action provider stub for quick fixes
|
|
134
|
+
const codeActionProvider = vscode.languages.registerCodeActionsProvider([
|
|
135
|
+
{ scheme: 'file', pattern: '**/*.object.ts' },
|
|
136
|
+
{ scheme: 'file', pattern: '**/*.view.ts' },
|
|
137
|
+
{ scheme: 'file', pattern: '**/objectstack.config.ts' },
|
|
138
|
+
], {
|
|
139
|
+
provideCodeActions(document, range, context) {
|
|
140
|
+
const actions = [];
|
|
141
|
+
for (const diagnostic of context.diagnostics) {
|
|
142
|
+
if (diagnostic.source !== 'objectstack')
|
|
143
|
+
continue;
|
|
144
|
+
// Quick fix: add missing label
|
|
145
|
+
if (diagnostic.message.includes('missing label')) {
|
|
146
|
+
const fix = new vscode.CodeAction('Add missing label property', vscode.CodeActionKind.QuickFix);
|
|
147
|
+
fix.diagnostics = [diagnostic];
|
|
148
|
+
fix.isPreferred = true;
|
|
149
|
+
actions.push(fix);
|
|
150
|
+
}
|
|
151
|
+
// Quick fix: convert to snake_case
|
|
152
|
+
if (diagnostic.message.includes('snake_case')) {
|
|
153
|
+
const fix = new vscode.CodeAction('Convert name to snake_case', vscode.CodeActionKind.QuickFix);
|
|
154
|
+
fix.diagnostics = [diagnostic];
|
|
155
|
+
actions.push(fix);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return actions;
|
|
159
|
+
},
|
|
160
|
+
}, { providedCodeActionKinds: [vscode.CodeActionKind.QuickFix] });
|
|
161
|
+
context.subscriptions.push(codeActionProvider);
|
|
162
|
+
// Validate open config files on activation
|
|
163
|
+
if (vscode.window.activeTextEditor) {
|
|
164
|
+
const uri = vscode.window.activeTextEditor.document.uri;
|
|
165
|
+
if (uri.fsPath.endsWith('objectstack.config.ts')) {
|
|
166
|
+
validateConfigFile(uri);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Basic validation for objectstack.config.ts files.
|
|
172
|
+
* Checks for common structural issues and reports diagnostics.
|
|
173
|
+
*/
|
|
174
|
+
function validateConfigFile(uri) {
|
|
175
|
+
const document = vscode.workspace.textDocuments.find((doc) => doc.uri.toString() === uri.toString());
|
|
176
|
+
if (!document)
|
|
177
|
+
return;
|
|
178
|
+
const diagnostics = [];
|
|
179
|
+
const text = document.getText();
|
|
180
|
+
// Check for missing manifest
|
|
181
|
+
if (text.includes('defineStack') && !text.includes('manifest')) {
|
|
182
|
+
const defineStackPos = text.indexOf('defineStack');
|
|
183
|
+
const pos = document.positionAt(defineStackPos);
|
|
184
|
+
diagnostics.push(new vscode.Diagnostic(new vscode.Range(pos, pos.translate(0, 'defineStack'.length)), 'defineStack requires a "manifest" property with name and version', vscode.DiagnosticSeverity.Warning));
|
|
185
|
+
}
|
|
186
|
+
// Check for camelCase object names (should be snake_case)
|
|
187
|
+
const nameMatches = text.matchAll(/name:\s*['"]([a-z][a-zA-Z]+)['"]/g);
|
|
188
|
+
for (const match of nameMatches) {
|
|
189
|
+
if (match[1] && /[A-Z]/.test(match[1]) && match.index !== undefined) {
|
|
190
|
+
const pos = document.positionAt(match.index);
|
|
191
|
+
const endPos = document.positionAt(match.index + match[0].length);
|
|
192
|
+
diagnostics.push(new vscode.Diagnostic(new vscode.Range(pos, endPos), `Object/field name "${match[1]}" should use snake_case (e.g. "${toSnakeCase(match[1])}")`, vscode.DiagnosticSeverity.Warning));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
diagnosticCollection.set(uri, diagnostics);
|
|
196
|
+
}
|
|
197
|
+
function toSnakeCase(str) {
|
|
198
|
+
return str.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
199
|
+
}
|
|
200
|
+
function deactivate() {
|
|
201
|
+
if (diagnosticCollection) {
|
|
202
|
+
diagnosticCollection.dispose();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;;;;;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
|
12
|
+
{ "open": "{", "close": "}" },
|
|
13
|
+
{ "open": "[", "close": "]" },
|
|
14
|
+
{ "open": "(", "close": ")" },
|
|
15
|
+
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
|
|
16
|
+
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
|
17
|
+
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }
|
|
18
|
+
]
|
|
19
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "objectstack-vscode",
|
|
3
|
+
"displayName": "ObjectStack",
|
|
4
|
+
"description": "ObjectStack Protocol — Autocomplete, validation, and inline diagnostics for .object.ts, .view.ts, and objectstack.config.ts files",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"publisher": "objectstack",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/nickmessing/spec"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"vscode": "^1.85.0"
|
|
14
|
+
},
|
|
15
|
+
"categories": [
|
|
16
|
+
"Programming Languages",
|
|
17
|
+
"Linters",
|
|
18
|
+
"Snippets"
|
|
19
|
+
],
|
|
20
|
+
"activationEvents": [
|
|
21
|
+
"workspaceContains:**/*.object.ts",
|
|
22
|
+
"workspaceContains:**/*.view.ts",
|
|
23
|
+
"workspaceContains:objectstack.config.ts"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/extension.js",
|
|
26
|
+
"contributes": {
|
|
27
|
+
"jsonValidation": [
|
|
28
|
+
{
|
|
29
|
+
"fileMatch": "objectstack.json",
|
|
30
|
+
"url": "./schemas/objectstack.schema.json"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"languages": [
|
|
34
|
+
{
|
|
35
|
+
"id": "objectstack",
|
|
36
|
+
"aliases": [
|
|
37
|
+
"ObjectStack",
|
|
38
|
+
"objectstack"
|
|
39
|
+
],
|
|
40
|
+
"extensions": [
|
|
41
|
+
".object.ts",
|
|
42
|
+
".view.ts"
|
|
43
|
+
],
|
|
44
|
+
"configuration": "./language-configuration.json"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"snippets": [
|
|
48
|
+
{
|
|
49
|
+
"language": "typescript",
|
|
50
|
+
"path": "./snippets/objectstack.json"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/vscode": "^1.85.0",
|
|
56
|
+
"typescript": "^5.3.0",
|
|
57
|
+
"@vscode/vsce": "^3.0.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc -p ./tsconfig.json",
|
|
61
|
+
"watch": "tsc -watch -p ./tsconfig.json",
|
|
62
|
+
"package": "vsce package"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ObjectStack: Define Object": {
|
|
3
|
+
"prefix": "os-object",
|
|
4
|
+
"description": "Define a new ObjectStack business object",
|
|
5
|
+
"body": [
|
|
6
|
+
"import { Data } from '@objectstack/spec';",
|
|
7
|
+
"",
|
|
8
|
+
"const ${1:myObject}: Data.Object = {",
|
|
9
|
+
" name: '${2:my_object}',",
|
|
10
|
+
" label: '${3:My Object}',",
|
|
11
|
+
" pluralLabel: '${3:My Object}s',",
|
|
12
|
+
" ownership: 'own',",
|
|
13
|
+
" fields: {",
|
|
14
|
+
" name: {",
|
|
15
|
+
" type: 'text',",
|
|
16
|
+
" label: 'Name',",
|
|
17
|
+
" required: true,",
|
|
18
|
+
" maxLength: 255,",
|
|
19
|
+
" },",
|
|
20
|
+
" $0",
|
|
21
|
+
" },",
|
|
22
|
+
"};",
|
|
23
|
+
"",
|
|
24
|
+
"export default ${1:myObject};"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"ObjectStack: Text Field": {
|
|
28
|
+
"prefix": "os-field-text",
|
|
29
|
+
"description": "Add a text field to an object",
|
|
30
|
+
"body": [
|
|
31
|
+
"${1:field_name}: {",
|
|
32
|
+
" type: 'text',",
|
|
33
|
+
" label: '${2:Field Label}',",
|
|
34
|
+
" required: ${3|false,true|},",
|
|
35
|
+
" maxLength: ${4:255},",
|
|
36
|
+
"},"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"ObjectStack: Select Field": {
|
|
40
|
+
"prefix": "os-field-select",
|
|
41
|
+
"description": "Add a select (picklist) field to an object",
|
|
42
|
+
"body": [
|
|
43
|
+
"${1:status}: {",
|
|
44
|
+
" type: 'select',",
|
|
45
|
+
" label: '${2:Status}',",
|
|
46
|
+
" required: ${3|false,true|},",
|
|
47
|
+
" options: [",
|
|
48
|
+
" { label: '${4:Active}', value: '${5:active}' },",
|
|
49
|
+
" { label: '${6:Inactive}', value: '${7:inactive}' },",
|
|
50
|
+
" ],",
|
|
51
|
+
" defaultValue: '${5:active}',",
|
|
52
|
+
"},"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"ObjectStack: Lookup Field": {
|
|
56
|
+
"prefix": "os-field-lookup",
|
|
57
|
+
"description": "Add a lookup (reference) field to an object",
|
|
58
|
+
"body": [
|
|
59
|
+
"${1:related_object}: {",
|
|
60
|
+
" type: 'lookup',",
|
|
61
|
+
" label: '${2:Related Object}',",
|
|
62
|
+
" required: ${3|false,true|},",
|
|
63
|
+
" reference: {",
|
|
64
|
+
" object: '${4:target_object}',",
|
|
65
|
+
" labelField: '${5:name}',",
|
|
66
|
+
" },",
|
|
67
|
+
"},"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"ObjectStack: Grid List View": {
|
|
71
|
+
"prefix": "os-view-grid",
|
|
72
|
+
"description": "Define a grid list view for an object",
|
|
73
|
+
"body": [
|
|
74
|
+
"import { UI } from '@objectstack/spec';",
|
|
75
|
+
"",
|
|
76
|
+
"const ${1:myObject}ListView: UI.View = {",
|
|
77
|
+
" name: '${2:my_object}_list',",
|
|
78
|
+
" label: '${3:My Object} List',",
|
|
79
|
+
" type: 'list',",
|
|
80
|
+
" objectName: '${2:my_object}',",
|
|
81
|
+
" list: {",
|
|
82
|
+
" type: 'grid',",
|
|
83
|
+
" columns: [",
|
|
84
|
+
" { field: 'name', width: 200 },",
|
|
85
|
+
" $0",
|
|
86
|
+
" ],",
|
|
87
|
+
" defaultSort: { field: 'name', direction: 'asc' },",
|
|
88
|
+
" pageSize: 25,",
|
|
89
|
+
" },",
|
|
90
|
+
"};",
|
|
91
|
+
"",
|
|
92
|
+
"export default ${1:myObject}ListView;"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"ObjectStack: Automation Flow": {
|
|
96
|
+
"prefix": "os-flow",
|
|
97
|
+
"description": "Define an automation flow",
|
|
98
|
+
"body": [
|
|
99
|
+
"import { Automation } from '@objectstack/spec';",
|
|
100
|
+
"",
|
|
101
|
+
"const ${1:myFlow}: Automation.Flow = {",
|
|
102
|
+
" name: '${2:my_flow}',",
|
|
103
|
+
" label: '${3:My Flow}',",
|
|
104
|
+
" type: '${4|autolaunched,screen,schedule|}',",
|
|
105
|
+
" status: 'draft',",
|
|
106
|
+
" trigger: {",
|
|
107
|
+
" type: 'record_change',",
|
|
108
|
+
" object: '${5:my_object}',",
|
|
109
|
+
" events: ['after_insert', 'after_update'],",
|
|
110
|
+
" },",
|
|
111
|
+
" nodes: [",
|
|
112
|
+
" {",
|
|
113
|
+
" id: 'start',",
|
|
114
|
+
" type: 'start',",
|
|
115
|
+
" name: 'Start',",
|
|
116
|
+
" next: '${6:end}',",
|
|
117
|
+
" },",
|
|
118
|
+
" $0",
|
|
119
|
+
" ],",
|
|
120
|
+
"};",
|
|
121
|
+
"",
|
|
122
|
+
"export default ${1:myFlow};"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"ObjectStack: defineStack Boilerplate": {
|
|
126
|
+
"prefix": "os-stack",
|
|
127
|
+
"description": "Full defineStack boilerplate for objectstack.config.ts",
|
|
128
|
+
"body": [
|
|
129
|
+
"import { defineStack } from '@objectstack/spec';",
|
|
130
|
+
"",
|
|
131
|
+
"export default defineStack({",
|
|
132
|
+
" manifest: {",
|
|
133
|
+
" name: '${1:my_app}',",
|
|
134
|
+
" version: '${2:0.1.0}',",
|
|
135
|
+
" label: '${3:My Application}',",
|
|
136
|
+
" },",
|
|
137
|
+
" objects: [",
|
|
138
|
+
" $0",
|
|
139
|
+
" ],",
|
|
140
|
+
" views: [],",
|
|
141
|
+
" plugins: [],",
|
|
142
|
+
"});"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"ObjectStack: AI Agent Definition": {
|
|
146
|
+
"prefix": "os-agent",
|
|
147
|
+
"description": "Define an AI agent",
|
|
148
|
+
"body": [
|
|
149
|
+
"import { AI } from '@objectstack/spec';",
|
|
150
|
+
"",
|
|
151
|
+
"const ${1:myAgent}: AI.Agent = {",
|
|
152
|
+
" name: '${2:my_agent}',",
|
|
153
|
+
" label: '${3:My Agent}',",
|
|
154
|
+
" role: '${4:Assistant}',",
|
|
155
|
+
" instructions: '${5:You are a helpful assistant.}',",
|
|
156
|
+
" model: {",
|
|
157
|
+
" provider: '${6|openai,anthropic,google|}',",
|
|
158
|
+
" model: '${7:gpt-4o}',",
|
|
159
|
+
" },",
|
|
160
|
+
" tools: [",
|
|
161
|
+
" $0",
|
|
162
|
+
" ],",
|
|
163
|
+
"};",
|
|
164
|
+
"",
|
|
165
|
+
"export default ${1:myAgent};"
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
}
|
package/src/extension.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
+
|
|
3
|
+
import * as vscode from 'vscode';
|
|
4
|
+
|
|
5
|
+
/** Well-known ObjectStack field types for hover documentation */
|
|
6
|
+
const FIELD_TYPE_DOCS: Record<string, string> = {
|
|
7
|
+
text: 'Single-line text field (max 255 chars by default)',
|
|
8
|
+
textarea: 'Multi-line text area for longer content',
|
|
9
|
+
richtext: 'Rich text editor with HTML formatting',
|
|
10
|
+
number: 'Decimal number with configurable precision',
|
|
11
|
+
integer: 'Whole number without decimals',
|
|
12
|
+
currency: 'Monetary value with currency code',
|
|
13
|
+
boolean: 'True/false toggle',
|
|
14
|
+
date: 'Calendar date (no time)',
|
|
15
|
+
datetime: 'Date with time and timezone',
|
|
16
|
+
select: 'Single-choice picklist (requires `options`)',
|
|
17
|
+
multiselect: 'Multi-choice picklist (requires `options`)',
|
|
18
|
+
lookup: 'Reference to another object (requires `reference`)',
|
|
19
|
+
master_detail: 'Parent-child relationship with cascade delete',
|
|
20
|
+
formula: 'Computed field using expressions',
|
|
21
|
+
email: 'Email address with validation',
|
|
22
|
+
phone: 'Phone number',
|
|
23
|
+
url: 'URL with protocol validation',
|
|
24
|
+
image: 'Image file reference',
|
|
25
|
+
file: 'File attachment reference',
|
|
26
|
+
json: 'Arbitrary JSON data',
|
|
27
|
+
uuid: 'Universally unique identifier',
|
|
28
|
+
slug: 'URL-friendly identifier (auto-generated from name)',
|
|
29
|
+
rating: 'Numeric star rating',
|
|
30
|
+
color: 'Hex color value (#RRGGBB)',
|
|
31
|
+
vector: 'Numeric vector for AI embeddings and similarity search',
|
|
32
|
+
encrypted: 'Encrypted at rest — displayed masked in UI',
|
|
33
|
+
autonumber: 'Auto-incrementing display number',
|
|
34
|
+
geo_point: 'Geographic coordinates (lat/lng)',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** ObjectStack schema keywords for hover tooltips */
|
|
38
|
+
const SCHEMA_DOCS: Record<string, string> = {
|
|
39
|
+
defineStack: 'Define an ObjectStack project or plugin. Validates against ObjectStackDefinitionSchema.',
|
|
40
|
+
defineView: 'Type-safe helper to define a list or form view for an object.',
|
|
41
|
+
defineApp: 'Type-safe helper to define an application with navigation.',
|
|
42
|
+
defineFlow: 'Type-safe helper to define an automation flow.',
|
|
43
|
+
defineAgent: 'Type-safe helper to define an AI agent with tools and instructions.',
|
|
44
|
+
manifest: 'Project package configuration — name, version, label, and metadata.',
|
|
45
|
+
objects: 'Business object definitions with fields, validation, and relationships.',
|
|
46
|
+
views: 'List and form view configurations for object data display.',
|
|
47
|
+
flows: 'Automation flows — screen flows, auto-launched, or scheduled.',
|
|
48
|
+
agents: 'AI agent definitions with model config, tools, and instructions.',
|
|
49
|
+
actions: 'Button actions, batch operations, and URL redirects.',
|
|
50
|
+
dashboards: 'Analytics dashboard layouts with widget grids.',
|
|
51
|
+
permissions: 'Permission sets defining CRUD access per object and field.',
|
|
52
|
+
roles: 'User role hierarchy for access control.',
|
|
53
|
+
plugins: 'External plugins to load into the stack.',
|
|
54
|
+
ownership: "Record ownership model: 'own' (creator-owned) or 'shared'.",
|
|
55
|
+
objectName: 'Snake_case reference to a business object (e.g. project_task).',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
let diagnosticCollection: vscode.DiagnosticCollection;
|
|
59
|
+
|
|
60
|
+
export function activate(context: vscode.ExtensionContext): void {
|
|
61
|
+
diagnosticCollection = vscode.languages.createDiagnosticCollection('objectstack');
|
|
62
|
+
context.subscriptions.push(diagnosticCollection);
|
|
63
|
+
|
|
64
|
+
// Watch for objectstack.config.ts changes
|
|
65
|
+
const configWatcher = vscode.workspace.createFileSystemWatcher('**/objectstack.config.ts');
|
|
66
|
+
|
|
67
|
+
configWatcher.onDidChange((uri) => {
|
|
68
|
+
validateConfigFile(uri);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
configWatcher.onDidCreate((uri) => {
|
|
72
|
+
validateConfigFile(uri);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
context.subscriptions.push(configWatcher);
|
|
76
|
+
|
|
77
|
+
// Register hover provider for TypeScript files
|
|
78
|
+
const hoverProvider = vscode.languages.registerHoverProvider(
|
|
79
|
+
[
|
|
80
|
+
{ scheme: 'file', pattern: '**/*.object.ts' },
|
|
81
|
+
{ scheme: 'file', pattern: '**/*.view.ts' },
|
|
82
|
+
{ scheme: 'file', pattern: '**/objectstack.config.ts' },
|
|
83
|
+
{ scheme: 'file', language: 'typescript' },
|
|
84
|
+
],
|
|
85
|
+
{
|
|
86
|
+
provideHover(document, position) {
|
|
87
|
+
const range = document.getWordRangeAtPosition(position);
|
|
88
|
+
if (!range) return undefined;
|
|
89
|
+
|
|
90
|
+
const word = document.getText(range);
|
|
91
|
+
|
|
92
|
+
// Check schema-level keywords
|
|
93
|
+
if (SCHEMA_DOCS[word]) {
|
|
94
|
+
return new vscode.Hover(
|
|
95
|
+
new vscode.MarkdownString(`**ObjectStack** — \`${word}\`\n\n${SCHEMA_DOCS[word]}`),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Check field type values (e.g. type: 'text')
|
|
100
|
+
const line = document.lineAt(position.line).text;
|
|
101
|
+
const typeMatch = line.match(/type:\s*['"](\w+)['"]/);
|
|
102
|
+
if (typeMatch && FIELD_TYPE_DOCS[typeMatch[1]]) {
|
|
103
|
+
const fieldType = typeMatch[1];
|
|
104
|
+
if (word === fieldType || word === 'type') {
|
|
105
|
+
return new vscode.Hover(
|
|
106
|
+
new vscode.MarkdownString(
|
|
107
|
+
`**ObjectStack Field Type** — \`${fieldType}\`\n\n${FIELD_TYPE_DOCS[fieldType]}`,
|
|
108
|
+
),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return undefined;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
context.subscriptions.push(hoverProvider);
|
|
119
|
+
|
|
120
|
+
// Register code action provider stub for quick fixes
|
|
121
|
+
const codeActionProvider = vscode.languages.registerCodeActionsProvider(
|
|
122
|
+
[
|
|
123
|
+
{ scheme: 'file', pattern: '**/*.object.ts' },
|
|
124
|
+
{ scheme: 'file', pattern: '**/*.view.ts' },
|
|
125
|
+
{ scheme: 'file', pattern: '**/objectstack.config.ts' },
|
|
126
|
+
],
|
|
127
|
+
{
|
|
128
|
+
provideCodeActions(document, range, context) {
|
|
129
|
+
const actions: vscode.CodeAction[] = [];
|
|
130
|
+
|
|
131
|
+
for (const diagnostic of context.diagnostics) {
|
|
132
|
+
if (diagnostic.source !== 'objectstack') continue;
|
|
133
|
+
|
|
134
|
+
// Quick fix: add missing label
|
|
135
|
+
if (diagnostic.message.includes('missing label')) {
|
|
136
|
+
const fix = new vscode.CodeAction(
|
|
137
|
+
'Add missing label property',
|
|
138
|
+
vscode.CodeActionKind.QuickFix,
|
|
139
|
+
);
|
|
140
|
+
fix.diagnostics = [diagnostic];
|
|
141
|
+
fix.isPreferred = true;
|
|
142
|
+
actions.push(fix);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Quick fix: convert to snake_case
|
|
146
|
+
if (diagnostic.message.includes('snake_case')) {
|
|
147
|
+
const fix = new vscode.CodeAction(
|
|
148
|
+
'Convert name to snake_case',
|
|
149
|
+
vscode.CodeActionKind.QuickFix,
|
|
150
|
+
);
|
|
151
|
+
fix.diagnostics = [diagnostic];
|
|
152
|
+
actions.push(fix);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return actions;
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{ providedCodeActionKinds: [vscode.CodeActionKind.QuickFix] },
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
context.subscriptions.push(codeActionProvider);
|
|
163
|
+
|
|
164
|
+
// Validate open config files on activation
|
|
165
|
+
if (vscode.window.activeTextEditor) {
|
|
166
|
+
const uri = vscode.window.activeTextEditor.document.uri;
|
|
167
|
+
if (uri.fsPath.endsWith('objectstack.config.ts')) {
|
|
168
|
+
validateConfigFile(uri);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Basic validation for objectstack.config.ts files.
|
|
175
|
+
* Checks for common structural issues and reports diagnostics.
|
|
176
|
+
*/
|
|
177
|
+
function validateConfigFile(uri: vscode.Uri): void {
|
|
178
|
+
const document = vscode.workspace.textDocuments.find(
|
|
179
|
+
(doc) => doc.uri.toString() === uri.toString(),
|
|
180
|
+
);
|
|
181
|
+
if (!document) return;
|
|
182
|
+
|
|
183
|
+
const diagnostics: vscode.Diagnostic[] = [];
|
|
184
|
+
const text = document.getText();
|
|
185
|
+
|
|
186
|
+
// Check for missing manifest
|
|
187
|
+
if (text.includes('defineStack') && !text.includes('manifest')) {
|
|
188
|
+
const defineStackPos = text.indexOf('defineStack');
|
|
189
|
+
const pos = document.positionAt(defineStackPos);
|
|
190
|
+
diagnostics.push(
|
|
191
|
+
new vscode.Diagnostic(
|
|
192
|
+
new vscode.Range(pos, pos.translate(0, 'defineStack'.length)),
|
|
193
|
+
'defineStack requires a "manifest" property with name and version',
|
|
194
|
+
vscode.DiagnosticSeverity.Warning,
|
|
195
|
+
),
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Check for camelCase object names (should be snake_case)
|
|
200
|
+
const nameMatches = text.matchAll(/name:\s*['"]([a-z][a-zA-Z]+)['"]/g);
|
|
201
|
+
for (const match of nameMatches) {
|
|
202
|
+
if (match[1] && /[A-Z]/.test(match[1]) && match.index !== undefined) {
|
|
203
|
+
const pos = document.positionAt(match.index);
|
|
204
|
+
const endPos = document.positionAt(match.index + match[0].length);
|
|
205
|
+
diagnostics.push(
|
|
206
|
+
new vscode.Diagnostic(
|
|
207
|
+
new vscode.Range(pos, endPos),
|
|
208
|
+
`Object/field name "${match[1]}" should use snake_case (e.g. "${toSnakeCase(match[1])}")`,
|
|
209
|
+
vscode.DiagnosticSeverity.Warning,
|
|
210
|
+
),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
diagnosticCollection.set(uri, diagnostics);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function toSnakeCase(str: string): string {
|
|
219
|
+
return str.replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function deactivate(): void {
|
|
223
|
+
if (diagnosticCollection) {
|
|
224
|
+
diagnosticCollection.dispose();
|
|
225
|
+
}
|
|
226
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"sourceMap": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|