@wickermoney/plugin-sdk 0.0.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 (122) hide show
  1. package/LICENSE +202 -0
  2. package/dist/index.d.ts +16 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +13 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/manifest/CORE_TABLES.d.ts +8 -0
  7. package/dist/manifest/CORE_TABLES.d.ts.map +1 -0
  8. package/dist/manifest/CORE_TABLES.js +16 -0
  9. package/dist/manifest/CORE_TABLES.js.map +1 -0
  10. package/dist/manifest/CoreTableName.d.ts +4 -0
  11. package/dist/manifest/CoreTableName.d.ts.map +1 -0
  12. package/dist/manifest/CoreTableName.js +2 -0
  13. package/dist/manifest/CoreTableName.js.map +1 -0
  14. package/dist/manifest/ManifestParseResult.d.ts +13 -0
  15. package/dist/manifest/ManifestParseResult.d.ts.map +1 -0
  16. package/dist/manifest/ManifestParseResult.js +2 -0
  17. package/dist/manifest/ManifestParseResult.js.map +1 -0
  18. package/dist/manifest/PERMISSIONS.d.ts +9 -0
  19. package/dist/manifest/PERMISSIONS.d.ts.map +1 -0
  20. package/dist/manifest/PERMISSIONS.js +9 -0
  21. package/dist/manifest/PERMISSIONS.js.map +1 -0
  22. package/dist/manifest/PageContribution.d.ts +5 -0
  23. package/dist/manifest/PageContribution.d.ts.map +1 -0
  24. package/dist/manifest/PageContribution.js +2 -0
  25. package/dist/manifest/PageContribution.js.map +1 -0
  26. package/dist/manifest/Permission.d.ts +4 -0
  27. package/dist/manifest/Permission.d.ts.map +1 -0
  28. package/dist/manifest/Permission.js +2 -0
  29. package/dist/manifest/Permission.js.map +1 -0
  30. package/dist/manifest/PluginManifest.d.ts +5 -0
  31. package/dist/manifest/PluginManifest.d.ts.map +1 -0
  32. package/dist/manifest/PluginManifest.js +2 -0
  33. package/dist/manifest/PluginManifest.js.map +1 -0
  34. package/dist/manifest/REMOTE_ENTRY_TYPE.d.ts +15 -0
  35. package/dist/manifest/REMOTE_ENTRY_TYPE.d.ts.map +1 -0
  36. package/dist/manifest/REMOTE_ENTRY_TYPE.js +15 -0
  37. package/dist/manifest/REMOTE_ENTRY_TYPE.js.map +1 -0
  38. package/dist/manifest/SDK_MAJOR_VERSION.d.ts +8 -0
  39. package/dist/manifest/SDK_MAJOR_VERSION.d.ts.map +1 -0
  40. package/dist/manifest/SDK_MAJOR_VERSION.js +8 -0
  41. package/dist/manifest/SDK_MAJOR_VERSION.js.map +1 -0
  42. package/dist/manifest/TableGrant.d.ts +5 -0
  43. package/dist/manifest/TableGrant.d.ts.map +1 -0
  44. package/dist/manifest/TableGrant.js +2 -0
  45. package/dist/manifest/TableGrant.js.map +1 -0
  46. package/dist/manifest/WIDGET_SIZES.d.ts +6 -0
  47. package/dist/manifest/WIDGET_SIZES.d.ts.map +1 -0
  48. package/dist/manifest/WIDGET_SIZES.js +6 -0
  49. package/dist/manifest/WIDGET_SIZES.js.map +1 -0
  50. package/dist/manifest/WIDGET_SLOTS.d.ts +9 -0
  51. package/dist/manifest/WIDGET_SLOTS.d.ts.map +1 -0
  52. package/dist/manifest/WIDGET_SLOTS.js +13 -0
  53. package/dist/manifest/WIDGET_SLOTS.js.map +1 -0
  54. package/dist/manifest/WidgetContribution.d.ts +5 -0
  55. package/dist/manifest/WidgetContribution.d.ts.map +1 -0
  56. package/dist/manifest/WidgetContribution.js +2 -0
  57. package/dist/manifest/WidgetContribution.js.map +1 -0
  58. package/dist/manifest/WidgetSize.d.ts +4 -0
  59. package/dist/manifest/WidgetSize.d.ts.map +1 -0
  60. package/dist/manifest/WidgetSize.js +2 -0
  61. package/dist/manifest/WidgetSize.js.map +1 -0
  62. package/dist/manifest/WidgetSlot.d.ts +4 -0
  63. package/dist/manifest/WidgetSlot.d.ts.map +1 -0
  64. package/dist/manifest/WidgetSlot.js +2 -0
  65. package/dist/manifest/WidgetSlot.js.map +1 -0
  66. package/dist/manifest/checkRemoteEntry.d.ts +16 -0
  67. package/dist/manifest/checkRemoteEntry.d.ts.map +1 -0
  68. package/dist/manifest/checkRemoteEntry.js +29 -0
  69. package/dist/manifest/checkRemoteEntry.js.map +1 -0
  70. package/dist/manifest/federationName.d.ts +13 -0
  71. package/dist/manifest/federationName.d.ts.map +1 -0
  72. package/dist/manifest/federationName.js +15 -0
  73. package/dist/manifest/federationName.js.map +1 -0
  74. package/dist/manifest/index.d.ts +26 -0
  75. package/dist/manifest/index.d.ts.map +1 -0
  76. package/dist/manifest/index.js +17 -0
  77. package/dist/manifest/index.js.map +1 -0
  78. package/dist/manifest/isCompatible.d.ts +11 -0
  79. package/dist/manifest/isCompatible.d.ts.map +1 -0
  80. package/dist/manifest/isCompatible.js +14 -0
  81. package/dist/manifest/isCompatible.js.map +1 -0
  82. package/dist/manifest/pageContributionSchema.d.ts +18 -0
  83. package/dist/manifest/pageContributionSchema.d.ts.map +1 -0
  84. package/dist/manifest/pageContributionSchema.js +24 -0
  85. package/dist/manifest/pageContributionSchema.js.map +1 -0
  86. package/dist/manifest/pagePath.d.ts +11 -0
  87. package/dist/manifest/pagePath.d.ts.map +1 -0
  88. package/dist/manifest/pagePath.js +13 -0
  89. package/dist/manifest/pagePath.js.map +1 -0
  90. package/dist/manifest/parseManifest.d.ts +15 -0
  91. package/dist/manifest/parseManifest.d.ts.map +1 -0
  92. package/dist/manifest/parseManifest.js +31 -0
  93. package/dist/manifest/parseManifest.js.map +1 -0
  94. package/dist/manifest/pluginManifestSchema.d.ts +73 -0
  95. package/dist/manifest/pluginManifestSchema.d.ts.map +1 -0
  96. package/dist/manifest/pluginManifestSchema.js +66 -0
  97. package/dist/manifest/pluginManifestSchema.js.map +1 -0
  98. package/dist/manifest/remoteEntrySchema.d.ts +17 -0
  99. package/dist/manifest/remoteEntrySchema.d.ts.map +1 -0
  100. package/dist/manifest/remoteEntrySchema.js +47 -0
  101. package/dist/manifest/remoteEntrySchema.js.map +1 -0
  102. package/dist/manifest/tableGrantSchema.d.ts +18 -0
  103. package/dist/manifest/tableGrantSchema.d.ts.map +1 -0
  104. package/dist/manifest/tableGrantSchema.js +10 -0
  105. package/dist/manifest/tableGrantSchema.js.map +1 -0
  106. package/dist/manifest/widgetContributionSchema.d.ts +20 -0
  107. package/dist/manifest/widgetContributionSchema.d.ts.map +1 -0
  108. package/dist/manifest/widgetContributionSchema.js +19 -0
  109. package/dist/manifest/widgetContributionSchema.js.map +1 -0
  110. package/dist/manifest.d.ts +175 -0
  111. package/dist/manifest.d.ts.map +1 -0
  112. package/dist/manifest.js +148 -0
  113. package/dist/manifest.js.map +1 -0
  114. package/dist/range.d.ts +75 -0
  115. package/dist/range.d.ts.map +1 -0
  116. package/dist/range.js +86 -0
  117. package/dist/range.js.map +1 -0
  118. package/dist/runtime.d.ts +142 -0
  119. package/dist/runtime.d.ts.map +1 -0
  120. package/dist/runtime.js +36 -0
  121. package/dist/runtime.js.map +1 -0
  122. package/package.json +47 -0
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { WIDGET_SIZES } from './WIDGET_SIZES.js';
3
+ import { WIDGET_SLOTS } from './WIDGET_SLOTS.js';
4
+ /** Validates one entry of a manifest's `contributes.widgets`: a component the plugin mounts into a shell slot. */
5
+ export const widgetContributionSchema = z.object({
6
+ /** Identifier of the widget, unique within the plugin. */
7
+ id: z.string().min(1),
8
+ /** The place in the shell the widget mounts into. */
9
+ slot: z.enum(WIDGET_SLOTS),
10
+ /** Human-readable widget title. */
11
+ title: z.string().min(1),
12
+ /** Size the widget renders at until the user changes it. Defaults to `md`. */
13
+ defaultSize: z.enum(WIDGET_SIZES).default('md'),
14
+ /** Sort position within the slot, lowest first. Defaults to 100. */
15
+ order: z.number().int().default(100),
16
+ /** Name of the module the plugin's Module Federation build exposes for this widget. */
17
+ module: z.string().min(1),
18
+ });
19
+ //# sourceMappingURL=widgetContributionSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widgetContributionSchema.js","sourceRoot":"","sources":["../../src/manifest/widgetContributionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,kHAAkH;AAClH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,0DAA0D;IAC1D,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,qDAAqD;IACrD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;IAC1B,mCAAmC;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,8EAA8E;IAC9E,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IAC/C,oEAAoE;IACpE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;IACpC,uFAAuF;IACvF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1B,CAAC,CAAA"}
@@ -0,0 +1,175 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Major version of this SDK. A plugin declares the major it was built against;
4
+ * the host refuses anything newer than its own.
5
+ */
6
+ export declare const SDK_MAJOR_VERSION: 0;
7
+ /** Core tables a plugin may request access to. */
8
+ export declare const CORE_TABLES: readonly ["accounts", "transactions", "transaction_splits", "categories", "category_rules", "category_rule_conditions", "recurring_items"];
9
+ export type CoreTableName = (typeof CORE_TABLES)[number];
10
+ export declare const tableGrantSchema: z.ZodObject<{
11
+ table: z.ZodEnum<{
12
+ accounts: "accounts";
13
+ transactions: "transactions";
14
+ transaction_splits: "transaction_splits";
15
+ categories: "categories";
16
+ category_rules: "category_rules";
17
+ category_rule_conditions: "category_rule_conditions";
18
+ recurring_items: "recurring_items";
19
+ }>;
20
+ access: z.ZodEnum<{
21
+ read: "read";
22
+ write: "write";
23
+ }>;
24
+ }, z.core.$strip>;
25
+ export type TableGrant = z.infer<typeof tableGrantSchema>;
26
+ export declare const PERMISSIONS: readonly ["network:outbound", "schedule:daily", "notify"];
27
+ export type Permission = (typeof PERMISSIONS)[number];
28
+ /** Where on the shell a widget may mount. */
29
+ export declare const WIDGET_SLOTS: readonly ["dashboard.primary", "dashboard.secondary", "account.detail"];
30
+ export type WidgetSlot = (typeof WIDGET_SLOTS)[number];
31
+ export declare const WIDGET_SIZES: readonly ["sm", "md", "lg", "full"];
32
+ export type WidgetSize = (typeof WIDGET_SIZES)[number];
33
+ export declare const pageContributionSchema: z.ZodObject<{
34
+ path: z.ZodString;
35
+ title: z.ZodString;
36
+ nav: z.ZodOptional<z.ZodObject<{
37
+ label: z.ZodString;
38
+ icon: z.ZodOptional<z.ZodString>;
39
+ section: z.ZodDefault<z.ZodEnum<{
40
+ main: "main";
41
+ reports: "reports";
42
+ settings: "settings";
43
+ }>>;
44
+ order: z.ZodDefault<z.ZodNumber>;
45
+ }, z.core.$strip>>;
46
+ module: z.ZodString;
47
+ }, z.core.$strip>;
48
+ export type PageContribution = z.infer<typeof pageContributionSchema>;
49
+ export declare const widgetContributionSchema: z.ZodObject<{
50
+ id: z.ZodString;
51
+ slot: z.ZodEnum<{
52
+ "dashboard.primary": "dashboard.primary";
53
+ "dashboard.secondary": "dashboard.secondary";
54
+ "account.detail": "account.detail";
55
+ }>;
56
+ title: z.ZodString;
57
+ defaultSize: z.ZodDefault<z.ZodEnum<{
58
+ sm: "sm";
59
+ md: "md";
60
+ lg: "lg";
61
+ full: "full";
62
+ }>>;
63
+ order: z.ZodDefault<z.ZodNumber>;
64
+ module: z.ZodString;
65
+ }, z.core.$strip>;
66
+ export type WidgetContribution = z.infer<typeof widgetContributionSchema>;
67
+ export declare const pluginManifestSchema: z.ZodObject<{
68
+ id: z.ZodString;
69
+ name: z.ZodString;
70
+ version: z.ZodString;
71
+ description: z.ZodDefault<z.ZodString>;
72
+ author: z.ZodDefault<z.ZodString>;
73
+ sdkVersion: z.ZodNumber;
74
+ requiredTables: z.ZodDefault<z.ZodArray<z.ZodObject<{
75
+ table: z.ZodEnum<{
76
+ accounts: "accounts";
77
+ transactions: "transactions";
78
+ transaction_splits: "transaction_splits";
79
+ categories: "categories";
80
+ category_rules: "category_rules";
81
+ category_rule_conditions: "category_rule_conditions";
82
+ recurring_items: "recurring_items";
83
+ }>;
84
+ access: z.ZodEnum<{
85
+ read: "read";
86
+ write: "write";
87
+ }>;
88
+ }, z.core.$strip>>>;
89
+ permissions: z.ZodDefault<z.ZodArray<z.ZodEnum<{
90
+ "network:outbound": "network:outbound";
91
+ "schedule:daily": "schedule:daily";
92
+ notify: "notify";
93
+ }>>>;
94
+ remoteEntry: z.ZodString;
95
+ contributes: z.ZodDefault<z.ZodObject<{
96
+ pages: z.ZodDefault<z.ZodArray<z.ZodObject<{
97
+ path: z.ZodString;
98
+ title: z.ZodString;
99
+ nav: z.ZodOptional<z.ZodObject<{
100
+ label: z.ZodString;
101
+ icon: z.ZodOptional<z.ZodString>;
102
+ section: z.ZodDefault<z.ZodEnum<{
103
+ main: "main";
104
+ reports: "reports";
105
+ settings: "settings";
106
+ }>>;
107
+ order: z.ZodDefault<z.ZodNumber>;
108
+ }, z.core.$strip>>;
109
+ module: z.ZodString;
110
+ }, z.core.$strip>>>;
111
+ widgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
112
+ id: z.ZodString;
113
+ slot: z.ZodEnum<{
114
+ "dashboard.primary": "dashboard.primary";
115
+ "dashboard.secondary": "dashboard.secondary";
116
+ "account.detail": "account.detail";
117
+ }>;
118
+ title: z.ZodString;
119
+ defaultSize: z.ZodDefault<z.ZodEnum<{
120
+ sm: "sm";
121
+ md: "md";
122
+ lg: "lg";
123
+ full: "full";
124
+ }>>;
125
+ order: z.ZodDefault<z.ZodNumber>;
126
+ module: z.ZodString;
127
+ }, z.core.$strip>>>;
128
+ endpoints: z.ZodDefault<z.ZodBoolean>;
129
+ exporters: z.ZodDefault<z.ZodBoolean>;
130
+ }, z.core.$strip>>;
131
+ }, z.core.$strip>;
132
+ export type PluginManifest = z.infer<typeof pluginManifestSchema>;
133
+ /**
134
+ * True when the host can load a plugin built against `pluginSdkMajor`.
135
+ * Older majors are accepted; newer are refused — the same compatibility gate
136
+ * the previous C# PluginHost used, which worked well.
137
+ */
138
+ export declare function isCompatible(pluginSdkMajor: number, hostSdkMajor?: number): boolean;
139
+ export interface ManifestParseResult {
140
+ readonly manifest?: PluginManifest;
141
+ readonly error?: string;
142
+ }
143
+ /**
144
+ * Validates an untrusted manifest.
145
+ *
146
+ * Manifests arrive from the database and, later, from third-party packages, so
147
+ * they are parsed rather than cast. A malformed one is a load failure for that
148
+ * plugin alone — never a crash of the host.
149
+ */
150
+ export declare function parseManifest(input: unknown): ManifestParseResult;
151
+ /**
152
+ * Module Federation container name for a plugin id.
153
+ *
154
+ * MF names must be valid JS identifiers, but plugin ids are reverse-domain. Both
155
+ * sides derive the name from the id with this function rather than writing it
156
+ * twice — a mismatch there fails at runtime with an opaque "remote not found".
157
+ */
158
+ export declare function federationName(pluginId: string): string;
159
+ /**
160
+ * How the host loads a plugin's remote entry.
161
+ *
162
+ * Plugins build with `target: 'esnext'` and Vite emits the entry as an ES module
163
+ * with top-level `import` statements. The federation runtime defaults to
164
+ * injecting a classic `<script>` tag, which parses that file as a script and
165
+ * fails with "Cannot use import statement outside a module" — one opaque error
166
+ * per widget, at mount time, long after the manifest validated. Declaring the
167
+ * type here makes the runtime use a dynamic `import()` instead.
168
+ *
169
+ * This is a contract, not a preference: a remote entry that is not an ES module
170
+ * will not load.
171
+ */
172
+ export declare const REMOTE_ENTRY_TYPE: "module";
173
+ /** Route a page contribution is mounted at. The host owns this prefix. */
174
+ export declare function pagePath(pluginId: string, contribution: PageContribution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;;;;;;;;;;;;iBAoC/B,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,EACtB,YAAY,GAAE,MAA0B,GACvC,OAAO,CAET;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAejE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAG,QAAiB,CAAA;AAElD,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,GAAG,MAAM,CAGjF"}
@@ -0,0 +1,148 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Major version of this SDK. A plugin declares the major it was built against;
4
+ * the host refuses anything newer than its own.
5
+ */
6
+ export const SDK_MAJOR_VERSION = 0;
7
+ /** Core tables a plugin may request access to. */
8
+ export const CORE_TABLES = [
9
+ 'accounts',
10
+ 'transactions',
11
+ 'transaction_splits',
12
+ 'categories',
13
+ 'category_rules',
14
+ 'category_rule_conditions',
15
+ 'recurring_items',
16
+ ];
17
+ export const tableGrantSchema = z.object({
18
+ table: z.enum(CORE_TABLES),
19
+ access: z.enum(['read', 'write']),
20
+ });
21
+ export const PERMISSIONS = ['network:outbound', 'schedule:daily', 'notify'];
22
+ /** Where on the shell a widget may mount. */
23
+ export const WIDGET_SLOTS = [
24
+ 'dashboard.primary',
25
+ 'dashboard.secondary',
26
+ 'account.detail',
27
+ ];
28
+ export const WIDGET_SIZES = ['sm', 'md', 'lg', 'full'];
29
+ export const pageContributionSchema = z.object({
30
+ /** Mounted at /p/<pluginId>/<path>. The host owns the prefix. */
31
+ path: z.string().min(1),
32
+ title: z.string().min(1),
33
+ nav: z
34
+ .object({
35
+ label: z.string().min(1),
36
+ icon: z.string().min(1).optional(),
37
+ section: z.enum(['main', 'reports', 'settings']).default('main'),
38
+ order: z.number().int().default(100),
39
+ })
40
+ .optional(),
41
+ /** Name exposed by the plugin's Module Federation build. */
42
+ module: z.string().min(1),
43
+ });
44
+ export const widgetContributionSchema = z.object({
45
+ id: z.string().min(1),
46
+ slot: z.enum(WIDGET_SLOTS),
47
+ title: z.string().min(1),
48
+ defaultSize: z.enum(WIDGET_SIZES).default('md'),
49
+ order: z.number().int().default(100),
50
+ module: z.string().min(1),
51
+ });
52
+ export const pluginManifestSchema = z.object({
53
+ /** Reverse-domain, stable across versions. e.g. "fioneer.insights" */
54
+ id: z.string().regex(/^[a-z0-9]+(\.[a-z0-9-]+)+$/, 'Must be reverse-domain, e.g. fioneer.insights'),
55
+ name: z.string().min(1),
56
+ version: z.string().min(1),
57
+ description: z.string().default(''),
58
+ author: z.string().default(''),
59
+ sdkVersion: z.number().int().nonnegative(),
60
+ requiredTables: z.array(tableGrantSchema).default([]),
61
+ permissions: z.array(z.enum(PERMISSIONS)).default([]),
62
+ /**
63
+ * URL of the Module Federation entry. Relative paths resolve against the host.
64
+ *
65
+ * The entry must be an ES module: the host registers every remote with
66
+ * `type: 'module'` and loads it with a dynamic `import()`, never a classic
67
+ * script tag. See `REMOTE_ENTRY_TYPE`.
68
+ */
69
+ remoteEntry: z.string().min(1),
70
+ contributes: z
71
+ .object({
72
+ pages: z.array(pageContributionSchema).default([]),
73
+ widgets: z.array(widgetContributionSchema).default([]),
74
+ endpoints: z.boolean().default(false),
75
+ /**
76
+ * True if the plugin can produce its own rows for a full data export.
77
+ *
78
+ * Same trust boundary as `endpoints`, and for the same reason: an
79
+ * exporter runs server-side code that reads a plugin's own schema, which
80
+ * only a bundled plugin's code is reviewed and sandboxed enough to do.
81
+ * Core does not know `plugin_budgets` or `plugin_import_csv` exist —
82
+ * this is the contribution point that lets an "export everything"
83
+ * feature include them without core ever naming them.
84
+ */
85
+ exporters: z.boolean().default(false),
86
+ })
87
+ .default({ pages: [], widgets: [], endpoints: false, exporters: false }),
88
+ });
89
+ /**
90
+ * True when the host can load a plugin built against `pluginSdkMajor`.
91
+ * Older majors are accepted; newer are refused — the same compatibility gate
92
+ * the previous C# PluginHost used, which worked well.
93
+ */
94
+ export function isCompatible(pluginSdkMajor, hostSdkMajor = SDK_MAJOR_VERSION) {
95
+ return Number.isInteger(pluginSdkMajor) && pluginSdkMajor <= hostSdkMajor;
96
+ }
97
+ /**
98
+ * Validates an untrusted manifest.
99
+ *
100
+ * Manifests arrive from the database and, later, from third-party packages, so
101
+ * they are parsed rather than cast. A malformed one is a load failure for that
102
+ * plugin alone — never a crash of the host.
103
+ */
104
+ export function parseManifest(input) {
105
+ const parsed = pluginManifestSchema.safeParse(input);
106
+ if (!parsed.success) {
107
+ return {
108
+ error: parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('; '),
109
+ };
110
+ }
111
+ if (!isCompatible(parsed.data.sdkVersion)) {
112
+ return {
113
+ error: `built against SDK v${parsed.data.sdkVersion}, host is v${SDK_MAJOR_VERSION} — ` +
114
+ `upgrade the host to load this plugin`,
115
+ };
116
+ }
117
+ return { manifest: parsed.data };
118
+ }
119
+ /**
120
+ * Module Federation container name for a plugin id.
121
+ *
122
+ * MF names must be valid JS identifiers, but plugin ids are reverse-domain. Both
123
+ * sides derive the name from the id with this function rather than writing it
124
+ * twice — a mismatch there fails at runtime with an opaque "remote not found".
125
+ */
126
+ export function federationName(pluginId) {
127
+ return pluginId.replace(/[^a-zA-Z0-9_]/g, '_');
128
+ }
129
+ /**
130
+ * How the host loads a plugin's remote entry.
131
+ *
132
+ * Plugins build with `target: 'esnext'` and Vite emits the entry as an ES module
133
+ * with top-level `import` statements. The federation runtime defaults to
134
+ * injecting a classic `<script>` tag, which parses that file as a script and
135
+ * fails with "Cannot use import statement outside a module" — one opaque error
136
+ * per widget, at mount time, long after the manifest validated. Declaring the
137
+ * type here makes the runtime use a dynamic `import()` instead.
138
+ *
139
+ * This is a contract, not a preference: a remote entry that is not an ES module
140
+ * will not load.
141
+ */
142
+ export const REMOTE_ENTRY_TYPE = 'module';
143
+ /** Route a page contribution is mounted at. The host owns this prefix. */
144
+ export function pagePath(pluginId, contribution) {
145
+ const clean = contribution.path.replace(/^\/+/, '');
146
+ return `/p/${pluginId}/${clean}`;
147
+ }
148
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAU,CAAA;AAE3C,kDAAkD;AAClD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU;IACV,cAAc;IACd,oBAAoB;IACpB,YAAY;IACZ,gBAAgB;IAChB,0BAA0B;IAC1B,iBAAiB;CACT,CAAA;AAGV,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,CAAU,CAAA;AAGpF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,mBAAmB;IACnB,qBAAqB;IACrB,gBAAgB;CACR,CAAA;AAGV,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,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AChD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAiB,CAAA;AAElD,0EAA0E;AAC1E,MAAM,UAAU,QAAQ,CAAC,QAAgB,EAAE,YAA8B;IACvE,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACnD,OAAO,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAA;AAClC,CAAC"}
@@ -0,0 +1,75 @@
1
+ /** Keys of the time ranges the dashboard offers: `Nm` for the last N whole months, `ytd` for year to date. */
2
+ export declare const RANGE_KEYS: readonly ["1m", "3m", "6m", "12m", "24m", "ytd"];
3
+ /** One of the range keys in `RANGE_KEYS`. */
4
+ export type RangeKey = (typeof RANGE_KEYS)[number];
5
+ /**
6
+ * The dashboard's time range, as every widget receives it.
7
+ *
8
+ * Passed down as a prop rather than published on a bus. A bus would need a
9
+ * subscription, a teardown and an initial value, and it would make two widgets
10
+ * able to observe each other — which is the coupling the plugin boundary exists
11
+ * to prevent. A prop is the same information with none of that: the host owns
12
+ * the control, React re-renders the widgets, and a widget that does not care
13
+ * about time simply ignores it.
14
+ *
15
+ * Both shapes are provided deliberately. `months` is what the existing
16
+ * aggregate endpoints already take, so nothing has to change to honour a range;
17
+ * `from`/`to` are resolved calendar dates for anything that needs to be exact.
18
+ * Offering only `months` would make "year to date" inexpressible, and offering
19
+ * only dates would break every endpoint that counts in months.
20
+ */
21
+ export interface DashboardRange {
22
+ /** Which range this is. */
23
+ readonly key: RangeKey;
24
+ /** What the control shows. Short enough for a compact segmented control. */
25
+ readonly label: string;
26
+ /** Whole months covered, including the current one. */
27
+ readonly months: number;
28
+ /** Inclusive first day, `YYYY-MM-DD`. */
29
+ readonly from: string;
30
+ /** Exclusive last day, `YYYY-MM-DD`. Half-open, like every period in the app. */
31
+ readonly to: string;
32
+ }
33
+ /** The range the dashboard starts on: the last 12 months. */
34
+ export declare const DEFAULT_RANGE_KEY: RangeKey;
35
+ /**
36
+ * Narrows a string to a `RangeKey`.
37
+ *
38
+ * @param value - Any string, typically read from a URL or stored setting.
39
+ * @returns `true` when `value` is one of `RANGE_KEYS`.
40
+ */
41
+ export declare function isRangeKey(value: string): value is RangeKey;
42
+ /**
43
+ * Looks up the control's label for a key without resolving dates.
44
+ *
45
+ * @param key - The range key.
46
+ * @returns The short label shown on the range control, e.g. `Year to date`.
47
+ */
48
+ export declare function rangeLabel(key: RangeKey): string;
49
+ /**
50
+ * Resolves a key against a given day, which is the user's today in their zone.
51
+ *
52
+ * `today` is passed in rather than read from a clock so the same call always
53
+ * gives the same answer — a range that silently depends on when it is evaluated
54
+ * cannot be tested, and would put the host and a widget on different days
55
+ * either side of midnight.
56
+ *
57
+ * Ranges end at the end of `today`'s month, not at today. A chart whose last
58
+ * bar is a part-month that shrinks as you look at it invites the reader to
59
+ * compare a half month against whole ones, which is the most common way a
60
+ * spending trend lies.
61
+ *
62
+ * @param key - The range to resolve.
63
+ * @param today - The current day as `YYYY-MM-DD`, in the user's time zone.
64
+ * @returns The range with its label, month count and half-open `from`/`to` dates.
65
+ */
66
+ export declare function resolveRange(key: RangeKey, today: string): DashboardRange;
67
+ /**
68
+ * Lists every month a range covers.
69
+ *
70
+ * @param range - A resolved range.
71
+ * @returns The months from `range.from` up to but not including `range.to`,
72
+ * oldest first, each as `YYYY-MM`.
73
+ */
74
+ export declare function monthsInRange(range: DashboardRange): string[];
75
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,eAAO,MAAM,UAAU,kDAAmD,CAAA;AAC1E,6CAA6C;AAC7C,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAElD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC7B,2BAA2B;IAC3B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CACpB;AAED,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,EAAE,QAAgB,CAAA;AAEhD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAE3D;AAYD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAEhD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAezE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,EAAE,CAS7D"}
package/dist/range.js ADDED
@@ -0,0 +1,86 @@
1
+ /** Keys of the time ranges the dashboard offers: `Nm` for the last N whole months, `ytd` for year to date. */
2
+ export const RANGE_KEYS = ['1m', '3m', '6m', '12m', '24m', 'ytd'];
3
+ /** The range the dashboard starts on: the last 12 months. */
4
+ export const DEFAULT_RANGE_KEY = '12m';
5
+ /**
6
+ * Narrows a string to a `RangeKey`.
7
+ *
8
+ * @param value - Any string, typically read from a URL or stored setting.
9
+ * @returns `true` when `value` is one of `RANGE_KEYS`.
10
+ */
11
+ export function isRangeKey(value) {
12
+ return RANGE_KEYS.includes(value);
13
+ }
14
+ /** Short control label for each range key. */
15
+ const LABELS = {
16
+ '1m': 'This month',
17
+ '3m': '3 months',
18
+ '6m': '6 months',
19
+ '12m': '12 months',
20
+ '24m': '24 months',
21
+ ytd: 'Year to date',
22
+ };
23
+ /**
24
+ * Looks up the control's label for a key without resolving dates.
25
+ *
26
+ * @param key - The range key.
27
+ * @returns The short label shown on the range control, e.g. `Year to date`.
28
+ */
29
+ export function rangeLabel(key) {
30
+ return LABELS[key];
31
+ }
32
+ /**
33
+ * Resolves a key against a given day, which is the user's today in their zone.
34
+ *
35
+ * `today` is passed in rather than read from a clock so the same call always
36
+ * gives the same answer — a range that silently depends on when it is evaluated
37
+ * cannot be tested, and would put the host and a widget on different days
38
+ * either side of midnight.
39
+ *
40
+ * Ranges end at the end of `today`'s month, not at today. A chart whose last
41
+ * bar is a part-month that shrinks as you look at it invites the reader to
42
+ * compare a half month against whole ones, which is the most common way a
43
+ * spending trend lies.
44
+ *
45
+ * @param key - The range to resolve.
46
+ * @param today - The current day as `YYYY-MM-DD`, in the user's time zone.
47
+ * @returns The range with its label, month count and half-open `from`/`to` dates.
48
+ */
49
+ export function resolveRange(key, today) {
50
+ const year = Number(today.slice(0, 4));
51
+ const month = Number(today.slice(5, 7));
52
+ const months = key === 'ytd' ? month : Number(key.replace('m', ''));
53
+ // Start at the first day of the month `months - 1` before this one.
54
+ const startAbsolute = year * 12 + (month - 1) - (months - 1);
55
+ const from = `${pad4(Math.floor(startAbsolute / 12))}-${pad2((startAbsolute % 12) + 1)}-01`;
56
+ // End exclusive: the first day of next month.
57
+ const endAbsolute = year * 12 + month;
58
+ const to = `${pad4(Math.floor(endAbsolute / 12))}-${pad2((endAbsolute % 12) + 1)}-01`;
59
+ return { key, label: LABELS[key], months, from, to };
60
+ }
61
+ /**
62
+ * Lists every month a range covers.
63
+ *
64
+ * @param range - A resolved range.
65
+ * @returns The months from `range.from` up to but not including `range.to`,
66
+ * oldest first, each as `YYYY-MM`.
67
+ */
68
+ export function monthsInRange(range) {
69
+ const out = [];
70
+ let absolute = Number(range.from.slice(0, 4)) * 12 + (Number(range.from.slice(5, 7)) - 1);
71
+ const end = Number(range.to.slice(0, 4)) * 12 + (Number(range.to.slice(5, 7)) - 1);
72
+ while (absolute < end) {
73
+ out.push(`${pad4(Math.floor(absolute / 12))}-${pad2((absolute % 12) + 1)}`);
74
+ absolute += 1;
75
+ }
76
+ return out;
77
+ }
78
+ /** Left-pads a number with zeros to two digits. */
79
+ function pad2(n) {
80
+ return String(n).padStart(2, '0');
81
+ }
82
+ /** Left-pads a number with zeros to four digits. */
83
+ function pad4(n) {
84
+ return String(n).padStart(4, '0');
85
+ }
86
+ //# sourceMappingURL=range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.js","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;AAiC1E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iBAAiB,GAAa,KAAK,CAAA;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAQ,UAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC1D,CAAC;AAED,8CAA8C;AAC9C,MAAM,MAAM,GAA6B;IACvC,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,cAAc;CACpB,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAa;IACtC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAC,GAAa,EAAE,KAAa;IACvD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,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