@documentdb-js/shell-api-types 0.8.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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @documentdb-js/shell-api-types
2
+
3
+ [DocumentDB](https://documentdb.io/) is an open-source document database built on PostgreSQL, with native BSON support, rich indexing, and vector search. It uses the MongoDB-compatible wire protocol, runs locally with Docker, and is MIT licensed.
4
+
5
+ This package provides TypeScript type definitions and a structured method-to-command registry for the DocumentDB shell API — everything needed to build IntelliSense, documentation tooling, or compatibility checks for the DocumentDB shell surface.
6
+
7
+ > **Pre-1.0 notice** — The API may change between minor versions until `1.0.0` is released.
8
+ > If you depend on this package and need stability guarantees sooner, please
9
+ > [open an issue](https://github.com/microsoft/vscode-documentdb/issues) and let us know.
10
+
11
+ ## What This Package Provides
12
+
13
+ 1. **`documentdb-shell-api.d.ts`** — TypeScript declarations for the DocumentDB
14
+ shell API surface (database methods, collection methods, cursor methods, BSON
15
+ constructors, and shell globals). Can be injected into a TS Server Plugin
16
+ for autocompletion, hover documentation, and signature help.
17
+
18
+ 2. **Method registry** — A structured mapping of every shell method to its
19
+ underlying DocumentDB server command(s). Methods that are client-side only
20
+ (e.g., `use()`, `help()`, `getSiblingDB()`) are flagged as `shellOnly`.
21
+
22
+ 3. **Compatibility verification** — A script that checks the method registry
23
+ against the official
24
+ [DocumentDB compatibility documentation](https://learn.microsoft.com/en-us/azure/documentdb/compatibility-query-language)
25
+ to detect when the upstream support matrix changes.
26
+
27
+ ## How the API Surface Was Determined
28
+
29
+ DocumentDB uses the MongoDB wire protocol. As stated in the
30
+ [official compatibility documentation](https://learn.microsoft.com/en-us/azure/documentdb/compatibility-query-language):
31
+
32
+ > "Client-side wrapper functions, such as `deleteMany()` and `updateMany()`,
33
+ > internally invoke the corresponding server commands (`delete()` and
34
+ > `update()`). Any function that relies on supported server commands is
35
+ > compatible with Azure DocumentDB."
36
+
37
+ The methods in this package were **manually selected** to provide a productive
38
+ shell editing experience. Each method maps to a server-side command listed
39
+ as supported in the DocumentDB compatibility matrix. All JSDoc
40
+ descriptions are original writing.
41
+
42
+ See [`typeDefs/README.md`](typeDefs/README.md) for the full list of reference
43
+ documentation pages.
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ npm install @documentdb-js/shell-api-types
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ```typescript
54
+ import {
55
+ getShellApiDtsContent,
56
+ SHELL_API_METHODS,
57
+ getRequiredServerCommands,
58
+ getMethodsByTarget,
59
+ } from '@documentdb-js/shell-api-types';
60
+
61
+ // Get the .d.ts content as a string (for TS server plugin injection)
62
+ const dtsContent = getShellApiDtsContent();
63
+
64
+ // Get all methods for a specific target
65
+ const collectionMethods = getMethodsByTarget('collection');
66
+
67
+ // Get the list of server commands the shell API depends on
68
+ const serverCommands = getRequiredServerCommands();
69
+ ```
70
+
71
+ ## Scripts
72
+
73
+ | Script | Description |
74
+ | ---------------- | -------------------------------------------------------------------- |
75
+ | `npm run build` | Compile TypeScript sources |
76
+ | `npm run test` | Run unit tests (method registry) |
77
+ | `npm run verify` | Check method registry against official DocumentDB compatibility docs |
78
+
79
+ ### Verification (`npm run verify`)
80
+
81
+ The `verify` script fetches the official DocumentDB compatibility page,
82
+ extracts the Database Commands table, and checks that every server command
83
+ referenced by the shell API is still marked as supported.
84
+
85
+ **Output keys** (for CI `grep`/`contains` checks):
86
+
87
+ | Key | Meaning |
88
+ | --------------------------------- | ---------------------------------------------------------------- |
89
+ | `[SHELL-API-COMPATIBLE]` | All server commands verified as supported — no action needed |
90
+ | `[SHELL-API-INCOMPATIBLE]` | A referenced command is no longer supported — update the `.d.ts` |
91
+ | `[SHELL-API-UNSUPPORTED-COMMAND]` | Per-command detail for each incompatible command |
92
+ | `[SHELL-API-MISSING-COMMAND]` | A referenced command was not found in the docs table |
93
+ | `[SHELL-API-NEW-COMMANDS]` | New supported commands found that could be added to the API |
94
+
95
+ The script also generates a full report at
96
+ `resources/scraped/compatibility-commands.md` with supported/unsupported command
97
+ tables and the complete method-to-command mapping.
98
+
99
+ ## Origin
100
+
101
+ This package was developed while building features for the [DocumentDB VS Code extension](https://github.com/microsoft/vscode-documentdb), which remains the primary consumer. The package is designed to be useful in any tooling that needs DocumentDB shell API type information or method metadata.
102
+
103
+ ## License
104
+
105
+ [MIT](LICENSE.md)
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @documentdb-js/shell-api-types
3
+ *
4
+ * Shell API type definitions and method-to-command mapping for DocumentDB
5
+ * query playground IntelliSense. This package provides:
6
+ *
7
+ * 1. The `.d.ts` content as a string — used by the TS Server Plugin to
8
+ * inject type declarations into query playground files.
9
+ * 2. A method registry mapping each shell method to its underlying server
10
+ * command(s) — used for compatibility verification.
11
+ * 3. A verification script (`npm run verify`) that checks the method
12
+ * registry against the official DocumentDB compatibility documentation.
13
+ */
14
+ export type { ShellMethodEntry } from './types';
15
+ export { SHELL_API_METHODS, getMethodsByTarget, getRequiredServerCommands } from './methodRegistry';
16
+ /**
17
+ * Returns the full content of the DocumentDB shell API `.d.ts` file.
18
+ * The content is read from disk once and cached in memory.
19
+ */
20
+ export declare function getShellApiDtsContent(): string;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AAGH,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAQpG;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAM9C"}
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.getRequiredServerCommands = exports.getMethodsByTarget = exports.SHELL_API_METHODS = void 0;
41
+ exports.getShellApiDtsContent = getShellApiDtsContent;
42
+ // Method registry
43
+ var methodRegistry_1 = require("./methodRegistry");
44
+ Object.defineProperty(exports, "SHELL_API_METHODS", { enumerable: true, get: function () { return methodRegistry_1.SHELL_API_METHODS; } });
45
+ Object.defineProperty(exports, "getMethodsByTarget", { enumerable: true, get: function () { return methodRegistry_1.getMethodsByTarget; } });
46
+ Object.defineProperty(exports, "getRequiredServerCommands", { enumerable: true, get: function () { return methodRegistry_1.getRequiredServerCommands; } });
47
+ // .d.ts content — loaded lazily on first access
48
+ const fs = __importStar(require("fs"));
49
+ const path = __importStar(require("path"));
50
+ let _dtsContent;
51
+ /**
52
+ * Returns the full content of the DocumentDB shell API `.d.ts` file.
53
+ * The content is read from disk once and cached in memory.
54
+ */
55
+ function getShellApiDtsContent() {
56
+ if (_dtsContent === undefined) {
57
+ const dtsPath = path.join(__dirname, '..', 'typeDefs', 'documentdb-shell-api.d.ts');
58
+ _dtsContent = fs.readFileSync(dtsPath, 'utf8');
59
+ }
60
+ return _dtsContent;
61
+ }
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgChG,sDAMC;AAnBD,kBAAkB;AAClB,mDAAoG;AAA3F,mHAAA,iBAAiB,OAAA;AAAE,oHAAA,kBAAkB,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAEzE,gDAAgD;AAChD,uCAAyB;AACzB,2CAA6B;AAE7B,IAAI,WAA+B,CAAC;AAEpC;;;GAGG;AACH,SAAgB,qBAAqB;IACjC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,2BAA2B,CAAC,CAAC;QACpF,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Shell API method registry — maps every method in the DocumentDB shell API
3
+ * `.d.ts` to its underlying server command(s).
4
+ *
5
+ * This registry serves two purposes:
6
+ * 1. Verification: the `verify` script checks that every server command
7
+ * listed here is still marked as supported in the official Azure
8
+ * DocumentDB compatibility documentation.
9
+ * 2. Reference: documents the relationship between client-side shell
10
+ * methods and the server commands they invoke.
11
+ *
12
+ * Methods are organized by target object (database, collection, cursor, global).
13
+ * Shell-only methods (no server command) are flagged with `shellOnly: true`.
14
+ */
15
+ import { type ShellMethodEntry } from './types';
16
+ /** All shell API methods across all target objects. */
17
+ export declare const SHELL_API_METHODS: readonly ShellMethodEntry[];
18
+ /**
19
+ * Returns all unique server commands referenced by the shell API methods.
20
+ * These are the commands that must be supported by the DocumentDB server
21
+ * for the shell API to function correctly.
22
+ */
23
+ export declare function getRequiredServerCommands(): readonly string[];
24
+ /**
25
+ * Returns methods filtered by target object.
26
+ */
27
+ export declare function getMethodsByTarget(target: ShellMethodEntry['target']): readonly ShellMethodEntry[];
28
+ //# sourceMappingURL=methodRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methodRegistry.d.ts","sourceRoot":"","sources":["../src/methodRegistry.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAwjBhD,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,EAAE,SAAS,gBAAgB,EAMxD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,SAAS,MAAM,EAAE,CAQ7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,SAAS,gBAAgB,EAAE,CAElG"}