@openwaggle/extension-sdk 0.0.0-bootstrap.0 → 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.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/dist/agent-loop.d.ts +128 -0
  5. package/dist/agent-loop.js +47 -0
  6. package/dist/broker-validation.d.ts +17 -0
  7. package/dist/broker-validation.js +99 -0
  8. package/dist/broker.d.ts +193 -0
  9. package/dist/broker.js +81 -0
  10. package/dist/constants.d.ts +183 -0
  11. package/dist/constants.js +245 -0
  12. package/dist/context.d.ts +66 -0
  13. package/dist/context.js +49 -0
  14. package/dist/contribution-types.d.ts +21 -0
  15. package/dist/contribution-types.js +1 -0
  16. package/dist/core-types.d.ts +58 -0
  17. package/dist/core-types.js +1 -0
  18. package/dist/docs-validation.d.ts +3 -0
  19. package/dist/docs-validation.js +93 -0
  20. package/dist/docs.d.ts +231 -0
  21. package/dist/docs.js +85 -0
  22. package/dist/index.d.ts +15 -0
  23. package/dist/index.js +10 -0
  24. package/dist/internal-validation.d.ts +4 -0
  25. package/dist/internal-validation.js +24 -0
  26. package/dist/json.d.ts +9 -0
  27. package/dist/json.js +3 -0
  28. package/dist/manifest-contributions.d.ts +380 -0
  29. package/dist/manifest-contributions.js +75 -0
  30. package/dist/manifest-primitives.d.ts +20 -0
  31. package/dist/manifest-primitives.js +118 -0
  32. package/dist/manifest.d.ts +303 -0
  33. package/dist/manifest.js +89 -0
  34. package/dist/openwaggle-sdk.d.ts +2 -0
  35. package/dist/openwaggle-sdk.js +127 -0
  36. package/dist/openwaggle-types.d.ts +111 -0
  37. package/dist/openwaggle-types.js +1 -0
  38. package/dist/openwaggle-validation.d.ts +12 -0
  39. package/dist/openwaggle-validation.js +135 -0
  40. package/dist/registry-types.d.ts +34 -0
  41. package/dist/registry-types.js +1 -0
  42. package/dist/runtime-sdk.d.ts +2 -0
  43. package/dist/runtime-sdk.js +19 -0
  44. package/dist/runtime-types.d.ts +19 -0
  45. package/dist/runtime-types.js +1 -0
  46. package/dist/runtime.d.ts +22 -0
  47. package/dist/runtime.js +22 -0
  48. package/dist/schema.d.ts +13 -0
  49. package/dist/schema.js +25 -0
  50. package/dist/sdk-types.d.ts +92 -0
  51. package/dist/sdk-types.js +1 -0
  52. package/dist/storage-sdk.d.ts +2 -0
  53. package/dist/storage-sdk.js +51 -0
  54. package/dist/storage-types.d.ts +40 -0
  55. package/dist/storage-types.js +1 -0
  56. package/dist/theme-data.d.ts +126 -0
  57. package/dist/theme-data.js +144 -0
  58. package/dist/theme-types.d.ts +61 -0
  59. package/dist/theme-types.js +1 -0
  60. package/dist/theme.d.ts +6 -0
  61. package/dist/theme.js +128 -0
  62. package/dist/types.d.ts +6 -0
  63. package/dist/types.js +1 -0
  64. package/dist/ui-constants.d.ts +24 -0
  65. package/dist/ui-constants.js +22 -0
  66. package/dist/ui-stylesheet.d.ts +8 -0
  67. package/dist/ui-stylesheet.js +223 -0
  68. package/dist/ui.d.ts +6 -0
  69. package/dist/ui.js +16 -0
  70. package/dist-cjs/agent-loop.js +83 -0
  71. package/dist-cjs/broker-validation.js +109 -0
  72. package/dist-cjs/broker.js +120 -0
  73. package/dist-cjs/constants.js +248 -0
  74. package/dist-cjs/context.js +54 -0
  75. package/dist-cjs/contribution-types.js +2 -0
  76. package/dist-cjs/core-types.js +2 -0
  77. package/dist-cjs/docs-validation.js +97 -0
  78. package/dist-cjs/docs.js +121 -0
  79. package/dist-cjs/index.js +56 -0
  80. package/dist-cjs/internal-validation.js +30 -0
  81. package/dist-cjs/json.js +39 -0
  82. package/dist-cjs/manifest-contributions.js +111 -0
  83. package/dist-cjs/manifest-primitives.js +158 -0
  84. package/dist-cjs/manifest.js +140 -0
  85. package/dist-cjs/openwaggle-sdk.js +130 -0
  86. package/dist-cjs/openwaggle-types.js +2 -0
  87. package/dist-cjs/openwaggle-validation.js +148 -0
  88. package/dist-cjs/package.json +3 -0
  89. package/dist-cjs/registry-types.js +2 -0
  90. package/dist-cjs/runtime-sdk.js +22 -0
  91. package/dist-cjs/runtime-types.js +2 -0
  92. package/dist-cjs/runtime.js +61 -0
  93. package/dist-cjs/schema.js +61 -0
  94. package/dist-cjs/sdk-types.js +2 -0
  95. package/dist-cjs/storage-sdk.js +54 -0
  96. package/dist-cjs/storage-types.js +2 -0
  97. package/dist-cjs/theme-data.js +147 -0
  98. package/dist-cjs/theme-types.js +2 -0
  99. package/dist-cjs/theme.js +135 -0
  100. package/dist-cjs/types.js +2 -0
  101. package/dist-cjs/ui-constants.js +25 -0
  102. package/dist-cjs/ui-stylesheet.js +227 -0
  103. package/dist-cjs/ui.js +24 -0
  104. package/package.json +98 -8
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.openWaggleExtensionManifestSchema = exports.extensionDocsSchema = exports.extensionDocsTopicDeclarationSchema = exports.extensionNetworkSchema = exports.extensionBuildSchema = exports.extensionInstallSchema = exports.extensionInstallSourceSchema = exports.extensionRuntimeRequirementSchema = exports.extensionRuntimeRequirementTypeSchema = exports.extensionSlotContributionFamilySchema = exports.extensionSemverVersionSchema = exports.extensionRelativePathSchema = exports.extensionIdSchema = exports.extensionExecutionPlacementSchema = exports.extensionContributionRuntimeSchema = exports.extensionContributionIdSchema = exports.extensionContributionFamilySchema = exports.extensionCommandContributionFamilySchema = exports.extensionCapabilityScopeSchema = void 0;
40
+ exports.defineExtensionManifest = defineExtensionManifest;
41
+ exports.validateExtensionManifest = validateExtensionManifest;
42
+ const Schema = __importStar(require("effect/Schema"));
43
+ const constants_js_1 = require("./constants.js");
44
+ const manifest_contributions_js_1 = require("./manifest-contributions.js");
45
+ const manifest_primitives_js_1 = require("./manifest-primitives.js");
46
+ const schema_js_1 = require("./schema.js");
47
+ __exportStar(require("./manifest-contributions.js"), exports);
48
+ var manifest_primitives_js_2 = require("./manifest-primitives.js");
49
+ Object.defineProperty(exports, "extensionCapabilityScopeSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionCapabilityScopeSchema; } });
50
+ Object.defineProperty(exports, "extensionCommandContributionFamilySchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionCommandContributionFamilySchema; } });
51
+ Object.defineProperty(exports, "extensionContributionFamilySchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionContributionFamilySchema; } });
52
+ Object.defineProperty(exports, "extensionContributionIdSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionContributionIdSchema; } });
53
+ Object.defineProperty(exports, "extensionContributionRuntimeSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionContributionRuntimeSchema; } });
54
+ Object.defineProperty(exports, "extensionExecutionPlacementSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionExecutionPlacementSchema; } });
55
+ Object.defineProperty(exports, "extensionIdSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionIdSchema; } });
56
+ Object.defineProperty(exports, "extensionRelativePathSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionRelativePathSchema; } });
57
+ Object.defineProperty(exports, "extensionSemverVersionSchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionSemverVersionSchema; } });
58
+ Object.defineProperty(exports, "extensionSlotContributionFamilySchema", { enumerable: true, get: function () { return manifest_primitives_js_2.extensionSlotContributionFamilySchema; } });
59
+ exports.extensionRuntimeRequirementTypeSchema = Schema.Literal(...constants_js_1.OPENWAGGLE_EXTENSION.RUNTIME_REQUIREMENT_TYPES);
60
+ exports.extensionRuntimeRequirementSchema = Schema.Struct({
61
+ id: manifest_primitives_js_1.extensionContributionIdSchema,
62
+ label: manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.maxLength(constants_js_1.OPENWAGGLE_EXTENSION.LIMITS.NAME_MAX_LENGTH)),
63
+ kind: Schema.optional(exports.extensionRuntimeRequirementTypeSchema),
64
+ command: Schema.optional(manifest_primitives_js_1.extensionRelativePathSchema),
65
+ binary: Schema.optional(manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.filter(manifest_primitives_js_1.isRuntimeRequirementBinary))),
66
+ }).pipe(Schema.filter((requirement) => {
67
+ const hasBinary = requirement.binary !== undefined;
68
+ const hasCommand = requirement.command !== undefined;
69
+ if (hasBinary === hasCommand) {
70
+ return 'Declare exactly one runtime requirement target: binary or command.';
71
+ }
72
+ if (hasBinary &&
73
+ requirement.kind !== undefined &&
74
+ requirement.kind !== constants_js_1.OPENWAGGLE_EXTENSION.RUNTIME_REQUIREMENT_TYPE.BINARY) {
75
+ return 'Runtime requirement kind must be "binary" when binary is declared.';
76
+ }
77
+ if (hasCommand &&
78
+ requirement.kind !== undefined &&
79
+ requirement.kind !== constants_js_1.OPENWAGGLE_EXTENSION.RUNTIME_REQUIREMENT_TYPE.COMMAND) {
80
+ return 'Runtime requirement kind must be "command" when command is declared.';
81
+ }
82
+ return true;
83
+ }));
84
+ exports.extensionInstallSourceSchema = Schema.Literal(...constants_js_1.OPENWAGGLE_EXTENSION.INSTALL_SOURCES);
85
+ exports.extensionInstallSchema = Schema.Struct({ source: exports.extensionInstallSourceSchema });
86
+ exports.extensionBuildSchema = Schema.Struct({
87
+ command: manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.filter(manifest_primitives_js_1.isBuildCommand)),
88
+ outputs: Schema.optional(Schema.Array(manifest_primitives_js_1.extensionRelativePathSchema)),
89
+ });
90
+ exports.extensionNetworkSchema = Schema.Struct({
91
+ origins: Schema.Array(manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.filter(manifest_primitives_js_1.isNetworkOrigin))),
92
+ });
93
+ exports.extensionDocsTopicDeclarationSchema = Schema.Struct({
94
+ id: manifest_primitives_js_1.extensionContributionIdSchema,
95
+ title: manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.maxLength(constants_js_1.OPENWAGGLE_EXTENSION.LIMITS.NAME_MAX_LENGTH)),
96
+ path: manifest_primitives_js_1.extensionRelativePathSchema,
97
+ description: Schema.optional(manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.maxLength(constants_js_1.OPENWAGGLE_EXTENSION.LIMITS.DESCRIPTION_MAX_LENGTH))),
98
+ aliases: Schema.optional(Schema.Array(manifest_primitives_js_1.extensionNonEmptyStringSchema)),
99
+ keywords: Schema.optional(Schema.Array(manifest_primitives_js_1.extensionNonEmptyStringSchema)),
100
+ });
101
+ exports.extensionDocsSchema = Schema.Struct({
102
+ topics: Schema.optional(Schema.Array(exports.extensionDocsTopicDeclarationSchema)),
103
+ });
104
+ function validateTrustedRendererRuntimeBoundary(manifest) {
105
+ const usesTrustedRenderer = constants_js_1.OPENWAGGLE_EXTENSION.ENTRY_CONTRIBUTION_FAMILIES.some((family) => manifest.contributions?.[family]?.some((contribution) => contribution.runtime === constants_js_1.OPENWAGGLE_EXTENSION.CONTRIBUTION_RUNTIME.TRUSTED_RENDERER));
106
+ return (!usesTrustedRenderer ||
107
+ manifest.trusted?.renderer !== undefined ||
108
+ 'Trusted renderer contributions require trusted.renderer to declare privileged renderer runtime execution.');
109
+ }
110
+ exports.openWaggleExtensionManifestSchema = Schema.Struct({
111
+ manifestVersion: Schema.Literal(1),
112
+ id: manifest_primitives_js_1.extensionIdSchema,
113
+ name: manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.maxLength(constants_js_1.OPENWAGGLE_EXTENSION.LIMITS.NAME_MAX_LENGTH)),
114
+ version: manifest_primitives_js_1.extensionSemverVersionSchema,
115
+ description: Schema.optional(manifest_primitives_js_1.extensionNonEmptyStringSchema.pipe(Schema.maxLength(constants_js_1.OPENWAGGLE_EXTENSION.LIMITS.DESCRIPTION_MAX_LENGTH))),
116
+ sdk: Schema.Struct({ openwaggle: manifest_primitives_js_1.extensionNonEmptyStringSchema }),
117
+ sourceFiles: Schema.Array(manifest_primitives_js_1.extensionRelativePathSchema),
118
+ builtArtifacts: Schema.Array(manifest_primitives_js_1.extensionRelativePathSchema),
119
+ install: Schema.optional(exports.extensionInstallSchema),
120
+ build: Schema.optional(exports.extensionBuildSchema),
121
+ docs: Schema.optional(exports.extensionDocsSchema),
122
+ network: Schema.optional(exports.extensionNetworkSchema),
123
+ capabilities: Schema.optional(Schema.Array(manifest_contributions_js_1.extensionCapabilityDeclarationSchema)),
124
+ contributions: Schema.optional(manifest_contributions_js_1.extensionContributionsSchema),
125
+ pi: Schema.optional(Schema.Struct({ resourceRoots: Schema.optional(Schema.Array(manifest_primitives_js_1.extensionRelativePathSchema)) })),
126
+ trusted: Schema.optional(Schema.Struct({
127
+ main: Schema.optional(manifest_primitives_js_1.extensionRelativePathSchema),
128
+ renderer: Schema.optional(manifest_primitives_js_1.extensionRelativePathSchema),
129
+ })),
130
+ runtimeRequirements: Schema.optional(Schema.Array(exports.extensionRuntimeRequirementSchema)),
131
+ }).pipe(Schema.filter(validateTrustedRendererRuntimeBoundary));
132
+ function defineExtensionManifest(manifest) {
133
+ return manifest;
134
+ }
135
+ function validateExtensionManifest(value) {
136
+ const result = (0, schema_js_1.safeDecodeExtensionSchema)(exports.openWaggleExtensionManifestSchema, value);
137
+ return result.success
138
+ ? { success: true, manifest: result.data }
139
+ : { success: false, issues: result.issues };
140
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOpenWaggleSdk = createOpenWaggleSdk;
4
+ const broker_validation_js_1 = require("./broker-validation.js");
5
+ const constants_js_1 = require("./constants.js");
6
+ const docs_validation_js_1 = require("./docs-validation.js");
7
+ const openwaggle_validation_js_1 = require("./openwaggle-validation.js");
8
+ const ACTION_RESULT_ERROR = 'Extension broker returned an invalid OpenWaggle action result.';
9
+ const DOCS_RESULT_ERROR = 'Extension broker returned an invalid OpenWaggle docs result.';
10
+ const SETTINGS_RESULT_ERROR = 'Extension broker returned an invalid OpenWaggle settings result.';
11
+ const STATE_RESULT_ERROR = 'Extension broker returned an invalid OpenWaggle state result.';
12
+ const unsupportedOpenExternal = async () => {
13
+ throw new Error('OpenWaggle external URL action is not available in this extension host context.');
14
+ };
15
+ function createOpenWaggleStateSdk(invoke) {
16
+ return {
17
+ get: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
18
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
19
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_STATE,
20
+ scope,
21
+ payload: {},
22
+ }), openwaggle_validation_js_1.isStateReadResult, STATE_RESULT_ERROR),
23
+ readCurrentProject: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
24
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
25
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE,
26
+ scope,
27
+ payload: { selector: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_PROJECT },
28
+ }), openwaggle_validation_js_1.isStateCurrentProjectReadResult, STATE_RESULT_ERROR),
29
+ readCurrentSession: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
30
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
31
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE,
32
+ scope,
33
+ payload: { selector: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_SESSION },
34
+ }), openwaggle_validation_js_1.isStateCurrentSessionReadResult, STATE_RESULT_ERROR),
35
+ readCurrentBranch: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
36
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
37
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE,
38
+ scope,
39
+ payload: { selector: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_BRANCH },
40
+ }), openwaggle_validation_js_1.isStateCurrentBranchReadResult, STATE_RESULT_ERROR),
41
+ readRecentProjects: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
42
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
43
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE,
44
+ scope,
45
+ payload: { selector: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.RECENT_PROJECTS },
46
+ }), openwaggle_validation_js_1.isStateRecentProjectsReadResult, STATE_RESULT_ERROR),
47
+ readModelPreferences: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
48
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE,
49
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE,
50
+ scope,
51
+ payload: { selector: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.MODEL_PREFERENCES },
52
+ }), openwaggle_validation_js_1.isStateModelPreferencesReadResult, STATE_RESULT_ERROR),
53
+ };
54
+ }
55
+ function createOpenWaggleSettingsSdk(invoke) {
56
+ return {
57
+ get: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
58
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
59
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SETTINGS,
60
+ scope,
61
+ payload: {},
62
+ }), openwaggle_validation_js_1.isSettingsGetResult, SETTINGS_RESULT_ERROR),
63
+ getModelPreferences: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
64
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
65
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SETTING,
66
+ scope,
67
+ payload: { key: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.MODEL_PREFERENCES },
68
+ }), openwaggle_validation_js_1.isSettingsGetSettingResult, SETTINGS_RESULT_ERROR),
69
+ updateModelPreferences: async (scope, value) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
70
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
71
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UPDATE_SETTING,
72
+ scope,
73
+ payload: { key: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.MODEL_PREFERENCES, value },
74
+ }), openwaggle_validation_js_1.isSettingsUpdateSettingResult, SETTINGS_RESULT_ERROR),
75
+ getProjectDisplayName: async (scope, projectPath) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
76
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
77
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SETTING,
78
+ scope,
79
+ payload: {
80
+ key: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.PROJECT_DISPLAY_NAME,
81
+ projectPath,
82
+ },
83
+ }), openwaggle_validation_js_1.isSettingsGetSettingResult, SETTINGS_RESULT_ERROR),
84
+ setProjectDisplayName: async (scope, projectPath, value) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
85
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
86
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UPDATE_SETTING,
87
+ scope,
88
+ payload: {
89
+ key: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.PROJECT_DISPLAY_NAME,
90
+ projectPath,
91
+ value,
92
+ },
93
+ }), openwaggle_validation_js_1.isSettingsUpdateSettingResult, SETTINGS_RESULT_ERROR),
94
+ update: async (scope, settings) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
95
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS,
96
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UPDATE_SETTINGS,
97
+ scope,
98
+ payload: settings,
99
+ }), openwaggle_validation_js_1.isSettingsUpdateResult, SETTINGS_RESULT_ERROR),
100
+ };
101
+ }
102
+ function createOpenWaggleSdk(invoke, options = {}) {
103
+ return {
104
+ state: createOpenWaggleStateSdk(invoke),
105
+ actions: {
106
+ openExternal: options.openExternal ?? unsupportedOpenExternal,
107
+ selectProject: async (scope, projectPath) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
108
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.ACTIONS,
109
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.SELECT_PROJECT,
110
+ scope,
111
+ payload: { projectPath },
112
+ }), openwaggle_validation_js_1.isActionSelectProjectResult, ACTION_RESULT_ERROR),
113
+ },
114
+ settings: createOpenWaggleSettingsSdk(invoke),
115
+ docs: {
116
+ discover: async (scope, input = {}) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
117
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.DOCS,
118
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.DISCOVER_DOCS,
119
+ scope,
120
+ payload: input,
121
+ }), docs_validation_js_1.isDocsDiscoverResult, DOCS_RESULT_ERROR),
122
+ resolveTopic: async (scope, input) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
123
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.DOCS,
124
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.RESOLVE_DOCS_TOPIC,
125
+ scope,
126
+ payload: input,
127
+ }), docs_validation_js_1.isDocsResolveTopicResult, DOCS_RESULT_ERROR),
128
+ },
129
+ };
130
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isStateReadResult = isStateReadResult;
4
+ exports.isStateCurrentProjectReadResult = isStateCurrentProjectReadResult;
5
+ exports.isStateCurrentSessionReadResult = isStateCurrentSessionReadResult;
6
+ exports.isStateCurrentBranchReadResult = isStateCurrentBranchReadResult;
7
+ exports.isStateRecentProjectsReadResult = isStateRecentProjectsReadResult;
8
+ exports.isStateModelPreferencesReadResult = isStateModelPreferencesReadResult;
9
+ exports.isActionSelectProjectResult = isActionSelectProjectResult;
10
+ exports.isSettingsGetResult = isSettingsGetResult;
11
+ exports.isSettingsUpdateResult = isSettingsUpdateResult;
12
+ exports.isSettingsGetSettingResult = isSettingsGetSettingResult;
13
+ exports.isSettingsUpdateSettingResult = isSettingsUpdateSettingResult;
14
+ const constants_js_1 = require("./constants.js");
15
+ const internal_validation_js_1 = require("./internal-validation.js");
16
+ function isStringOrNull(value) {
17
+ return value === null || typeof value === 'string';
18
+ }
19
+ function isInvokeScope(value) {
20
+ if (!(0, internal_validation_js_1.isRecord)(value)) {
21
+ return false;
22
+ }
23
+ if (value.kind === 'app') {
24
+ return true;
25
+ }
26
+ if (value.kind === 'project') {
27
+ return (0, internal_validation_js_1.isNonEmptyString)(value.projectPath);
28
+ }
29
+ if (value.kind === 'session') {
30
+ return (0, internal_validation_js_1.isNonEmptyString)(value.projectPath) && (0, internal_validation_js_1.isNonEmptyString)(value.sessionId);
31
+ }
32
+ return (value.kind === 'branch' &&
33
+ (0, internal_validation_js_1.isNonEmptyString)(value.projectPath) &&
34
+ (0, internal_validation_js_1.isNonEmptyString)(value.sessionId) &&
35
+ (0, internal_validation_js_1.isNonEmptyString)(value.branchId));
36
+ }
37
+ function isStringRecord(value) {
38
+ return (0, internal_validation_js_1.isRecord)(value) && Object.values(value).every((entry) => typeof entry === 'string');
39
+ }
40
+ function isModelPreferences(value) {
41
+ return ((0, internal_validation_js_1.isRecord)(value) &&
42
+ typeof value.selectedModel === 'string' &&
43
+ (0, internal_validation_js_1.isStringArray)(value.favoriteModels) &&
44
+ (0, internal_validation_js_1.isStringArray)(value.enabledModels) &&
45
+ typeof value.thinkingLevel === 'string');
46
+ }
47
+ function isProjectView(value) {
48
+ return ((0, internal_validation_js_1.isRecord)(value) &&
49
+ (0, internal_validation_js_1.isNonEmptyString)(value.projectPath) &&
50
+ isStringOrNull(value.displayName) &&
51
+ typeof value.active === 'boolean');
52
+ }
53
+ function isSessionView(value) {
54
+ return ((0, internal_validation_js_1.isRecord)(value) &&
55
+ (0, internal_validation_js_1.isNonEmptyString)(value.sessionId) &&
56
+ (0, internal_validation_js_1.isNonEmptyString)(value.title) &&
57
+ isStringOrNull(value.projectPath));
58
+ }
59
+ function isBranchView(value) {
60
+ return ((0, internal_validation_js_1.isRecord)(value) &&
61
+ (0, internal_validation_js_1.isNonEmptyString)(value.branchId) &&
62
+ (0, internal_validation_js_1.isNonEmptyString)(value.sessionId) &&
63
+ (0, internal_validation_js_1.isNonEmptyString)(value.name) &&
64
+ typeof value.main === 'boolean' &&
65
+ typeof value.archived === 'boolean');
66
+ }
67
+ function hasOpenWaggleResultBase(value, capability, method) {
68
+ return ((0, internal_validation_js_1.isNonEmptyString)(value.extensionId) &&
69
+ (0, internal_validation_js_1.isNonEmptyString)(value.contributionId) &&
70
+ value.capability === capability &&
71
+ value.method === method);
72
+ }
73
+ function isStateReadResult(value) {
74
+ return ((0, internal_validation_js_1.isRecord)(value) &&
75
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_STATE) &&
76
+ isInvokeScope(value.scope) &&
77
+ isStringOrNull(value.activeProjectPath) &&
78
+ (value.currentProject === null || isProjectView(value.currentProject)) &&
79
+ (value.currentSession === null || isSessionView(value.currentSession)) &&
80
+ (value.currentBranch === null || isBranchView(value.currentBranch)) &&
81
+ (0, internal_validation_js_1.isStringArray)(value.recentProjects) &&
82
+ isModelPreferences(value.modelPreferences));
83
+ }
84
+ function isSelectedStateResult(value, selector, isSelectedValue) {
85
+ return ((0, internal_validation_js_1.isRecord)(value) &&
86
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STATE, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.READ_STATE) &&
87
+ isInvokeScope(value.scope) &&
88
+ value.selector === selector &&
89
+ isSelectedValue(value.value));
90
+ }
91
+ function isStateCurrentProjectReadResult(value) {
92
+ return isSelectedStateResult(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_PROJECT, (selectedValue) => selectedValue === null || isProjectView(selectedValue));
93
+ }
94
+ function isStateCurrentSessionReadResult(value) {
95
+ return isSelectedStateResult(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_SESSION, (selectedValue) => selectedValue === null || isSessionView(selectedValue));
96
+ }
97
+ function isStateCurrentBranchReadResult(value) {
98
+ return isSelectedStateResult(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.CURRENT_BRANCH, (selectedValue) => selectedValue === null || isBranchView(selectedValue));
99
+ }
100
+ function isStateRecentProjectsReadResult(value) {
101
+ return isSelectedStateResult(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.RECENT_PROJECTS, internal_validation_js_1.isStringArray);
102
+ }
103
+ function isStateModelPreferencesReadResult(value) {
104
+ return isSelectedStateResult(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.STATE_SELECTOR.MODEL_PREFERENCES, isModelPreferences);
105
+ }
106
+ function isActionSelectProjectResult(value) {
107
+ return ((0, internal_validation_js_1.isRecord)(value) &&
108
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.ACTIONS, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.SELECT_PROJECT) &&
109
+ isStringOrNull(value.previousProjectPath) &&
110
+ (0, internal_validation_js_1.isNonEmptyString)(value.projectPath) &&
111
+ (0, internal_validation_js_1.isStringArray)(value.recentProjects));
112
+ }
113
+ function isSettingsView(value) {
114
+ return ((0, internal_validation_js_1.isRecord)(value) &&
115
+ isModelPreferences(value.modelPreferences) &&
116
+ isStringRecord(value.projectDisplayNames));
117
+ }
118
+ function isSettingsSelectedValue(value) {
119
+ if (!(0, internal_validation_js_1.isRecord)(value)) {
120
+ return false;
121
+ }
122
+ if (value.key === constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.MODEL_PREFERENCES) {
123
+ return isModelPreferences(value.value);
124
+ }
125
+ return (value.key === constants_js_1.OPENWAGGLE_EXTENSION_BROKER.SETTING_KEY.PROJECT_DISPLAY_NAME &&
126
+ (0, internal_validation_js_1.isNonEmptyString)(value.projectPath) &&
127
+ isStringOrNull(value.value));
128
+ }
129
+ function isSettingsGetResult(value) {
130
+ return ((0, internal_validation_js_1.isRecord)(value) &&
131
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SETTINGS) &&
132
+ isSettingsView(value.settings));
133
+ }
134
+ function isSettingsUpdateResult(value) {
135
+ return ((0, internal_validation_js_1.isRecord)(value) &&
136
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UPDATE_SETTINGS) &&
137
+ isSettingsView(value.settings));
138
+ }
139
+ function isSettingsGetSettingResult(value) {
140
+ return ((0, internal_validation_js_1.isRecord)(value) &&
141
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET_SETTING) &&
142
+ isSettingsSelectedValue(value.setting));
143
+ }
144
+ function isSettingsUpdateSettingResult(value) {
145
+ return ((0, internal_validation_js_1.isRecord)(value) &&
146
+ hasOpenWaggleResultBase(value, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.SETTINGS, constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UPDATE_SETTING) &&
147
+ isSettingsSelectedValue(value.setting));
148
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRuntimeContributionSdk = createRuntimeContributionSdk;
4
+ const broker_validation_js_1 = require("./broker-validation.js");
5
+ const constants_js_1 = require("./constants.js");
6
+ const RUNTIME_CONTRIBUTION_RESULT_ERROR = 'Extension broker returned an invalid runtime contribution result.';
7
+ function createRuntimeContributionSdk(invoke) {
8
+ return {
9
+ registerContribution: async (scope, registration) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
10
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.RUNTIME,
11
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.REGISTER_CONTRIBUTION,
12
+ scope,
13
+ payload: registration,
14
+ }), broker_validation_js_1.isRuntimeRegisterContributionResult, RUNTIME_CONTRIBUTION_RESULT_ERROR),
15
+ unregisterContribution: async (scope, unregistration) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
16
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.RUNTIME,
17
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UNREGISTER_CONTRIBUTION,
18
+ scope,
19
+ payload: unregistration,
20
+ }), broker_validation_js_1.isRuntimeUnregisterContributionResult, RUNTIME_CONTRIBUTION_RESULT_ERROR),
21
+ };
22
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.extensionRuntimeUnregisterContributionResultSchema = exports.extensionRuntimeRegisterContributionResultSchema = exports.createRuntimeContributionSdk = exports.extensionContributionUnregistrationSchema = exports.extensionContributionRegistrationSchema = void 0;
37
+ const Schema = __importStar(require("effect/Schema"));
38
+ const constants_js_1 = require("./constants.js");
39
+ const manifest_js_1 = require("./manifest.js");
40
+ var manifest_js_2 = require("./manifest.js");
41
+ Object.defineProperty(exports, "extensionContributionRegistrationSchema", { enumerable: true, get: function () { return manifest_js_2.extensionContributionRegistrationSchema; } });
42
+ Object.defineProperty(exports, "extensionContributionUnregistrationSchema", { enumerable: true, get: function () { return manifest_js_2.extensionContributionUnregistrationSchema; } });
43
+ var runtime_sdk_js_1 = require("./runtime-sdk.js");
44
+ Object.defineProperty(exports, "createRuntimeContributionSdk", { enumerable: true, get: function () { return runtime_sdk_js_1.createRuntimeContributionSdk; } });
45
+ exports.extensionRuntimeRegisterContributionResultSchema = Schema.Struct({
46
+ extensionId: manifest_js_1.extensionIdSchema,
47
+ contributionId: manifest_js_1.extensionContributionIdSchema,
48
+ capability: Schema.Literal(constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.RUNTIME),
49
+ method: Schema.Literal(constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.REGISTER_CONTRIBUTION),
50
+ family: manifest_js_1.extensionContributionFamilySchema,
51
+ registeredContributionId: manifest_js_1.extensionContributionIdSchema,
52
+ });
53
+ exports.extensionRuntimeUnregisterContributionResultSchema = Schema.Struct({
54
+ extensionId: manifest_js_1.extensionIdSchema,
55
+ contributionId: manifest_js_1.extensionContributionIdSchema,
56
+ capability: Schema.Literal(constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.RUNTIME),
57
+ method: Schema.Literal(constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.UNREGISTER_CONTRIBUTION),
58
+ family: manifest_js_1.extensionContributionFamilySchema,
59
+ unregisteredContributionId: manifest_js_1.extensionContributionIdSchema,
60
+ unregistered: Schema.Boolean,
61
+ });
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.safeDecodeExtensionSchema = safeDecodeExtensionSchema;
37
+ const ParseResult = __importStar(require("effect/ParseResult"));
38
+ function formatIssuePath(path) {
39
+ const joinedPath = path.map(String).join('.');
40
+ return joinedPath.length > 0 ? joinedPath : '(root)';
41
+ }
42
+ function formatParseError(error) {
43
+ return ParseResult.ArrayFormatter.formatErrorSync(error).map((issue) => `${formatIssuePath(issue.path)}: ${issue.message}`);
44
+ }
45
+ function safeDecodeExtensionSchema(schema, value) {
46
+ try {
47
+ return {
48
+ success: true,
49
+ data: ParseResult.decodeUnknownSync(schema)(value),
50
+ };
51
+ }
52
+ catch (error) {
53
+ if (ParseResult.isParseError(error)) {
54
+ return {
55
+ success: false,
56
+ issues: formatParseError(error),
57
+ };
58
+ }
59
+ throw error;
60
+ }
61
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPackageStorageSdk = createPackageStorageSdk;
4
+ const broker_validation_js_1 = require("./broker-validation.js");
5
+ const constants_js_1 = require("./constants.js");
6
+ const STORAGE_RESULT_ERROR = 'Extension broker returned an invalid storage result.';
7
+ function storagePayload(storageKind, storageScope, key, value) {
8
+ return {
9
+ storageKind,
10
+ storageScope,
11
+ ...(key !== undefined ? { key } : {}),
12
+ ...(value !== undefined ? { value } : {}),
13
+ };
14
+ }
15
+ function createStorageScopeSdk(invoke, storageKind, storageScope) {
16
+ return {
17
+ get: async (scope, key) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
18
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STORAGE,
19
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.GET,
20
+ scope,
21
+ payload: storagePayload(storageKind, storageScope, key),
22
+ }), broker_validation_js_1.isStorageGetResult, STORAGE_RESULT_ERROR),
23
+ set: async (scope, key, value) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
24
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STORAGE,
25
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.SET,
26
+ scope,
27
+ payload: storagePayload(storageKind, storageScope, key, value),
28
+ }), broker_validation_js_1.isStorageSetResult, STORAGE_RESULT_ERROR),
29
+ delete: async (scope, key) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
30
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STORAGE,
31
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.DELETE,
32
+ scope,
33
+ payload: storagePayload(storageKind, storageScope, key),
34
+ }), broker_validation_js_1.isStorageDeleteResult, STORAGE_RESULT_ERROR),
35
+ list: async (scope) => (0, broker_validation_js_1.toDecodedOperationResult)(await invoke({
36
+ capability: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.CAPABILITY.STORAGE,
37
+ method: constants_js_1.OPENWAGGLE_EXTENSION_BROKER.METHOD.LIST,
38
+ scope,
39
+ payload: storagePayload(storageKind, storageScope),
40
+ }), broker_validation_js_1.isStorageListResult, STORAGE_RESULT_ERROR),
41
+ };
42
+ }
43
+ function createStorageKindSdk(invoke, storageKind) {
44
+ return {
45
+ global: createStorageScopeSdk(invoke, storageKind, constants_js_1.OPENWAGGLE_EXTENSION.STORAGE.SCOPE.GLOBAL_KIND),
46
+ project: createStorageScopeSdk(invoke, storageKind, constants_js_1.OPENWAGGLE_EXTENSION.STORAGE.SCOPE.PROJECT_KIND),
47
+ };
48
+ }
49
+ function createPackageStorageSdk(invoke) {
50
+ return {
51
+ packageState: createStorageKindSdk(invoke, constants_js_1.OPENWAGGLE_EXTENSION.STORAGE.KIND.STATE),
52
+ packageConfig: createStorageKindSdk(invoke, constants_js_1.OPENWAGGLE_EXTENSION.STORAGE.KIND.CONFIG),
53
+ };
54
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });