@saasicat/ui-vue 0.3.0 → 0.5.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/README.md +47 -4
- package/dist/action-registry-CQ2wL3R-.d.cts +85 -0
- package/dist/action-registry-CQ2wL3R-.d.ts +85 -0
- package/dist/chunk-3YP2ZAOD.js +63 -0
- package/dist/chunk-EH7TOD4H.js +718 -0
- package/dist/chunk-LVGUSD3T.js +26 -0
- package/dist/client/index.cjs +785 -0
- package/dist/client/index.d.cts +295 -0
- package/dist/client/index.d.ts +295 -0
- package/dist/client/index.js +52 -0
- package/dist/index.cjs +787 -834
- package/dist/index.d.cts +267 -841
- package/dist/index.d.ts +267 -841
- package/dist/index.js +284 -1059
- package/dist/quasar/index.cjs +159 -0
- package/dist/quasar/index.d.cts +86 -0
- package/dist/quasar/index.d.ts +86 -0
- package/dist/quasar/index.js +91 -0
- package/dist/ui-notify-COUzXEQ4.d.ts +178 -0
- package/dist/ui-notify-D_eAAwRh.d.cts +178 -0
- package/package.json +23 -3
- package/src/client/index.ts +25 -0
- package/src/components/FeatureGate.vue +1 -1
- package/src/components/plan/PlanCycleToggle.vue +1 -1
- package/src/components/plan/PlanGrid.vue +2 -2
- package/src/components/plan/PriceSummary.vue +1 -1
- package/src/components/plan/PromoCodeInput.vue +1 -1
- package/src/components/plan/PublicBundleGrid.vue +1 -1
- package/src/index.ts +82 -79
- package/src/pages-standard/AdminLayout.vue +2 -2
- package/src/pages-standard/DashboardPage.vue +2 -2
- package/src/pages-standard/EmailHistoryPage.vue +9 -13
- package/src/pages-standard/MarketingCatalogPage.vue +5 -5
- package/src/pages-standard/PilotsPage.vue +9 -13
- package/src/pages-standard/PlanVersionsPage.vue +2 -2
- package/src/pages-standard/PlansPage.vue +2 -2
- package/src/pages-standard/PlatformEmailPage.vue +7 -5
- package/src/pages-standard/PromoCodesPage.vue +8 -22
- package/src/pages-standard/SuperAdminLoginPage.vue +3 -3
- package/src/pages-standard/SuperAdminSetupWizard.vue +2 -2
- package/src/pages-standard/TenantDetailPage.vue +4 -4
- package/src/pages-standard/TenantsPage.vue +3 -3
- package/src/pages-standard/UsersPage.vue +6 -12
- package/src/pages-standard/plan-versions/PlanVersionHeader.vue +1 -1
- package/src/pages-standard/plan-versions/PlanVersionsAudit.vue +1 -1
- package/src/pages-standard/plan-versions/PlanVersionsDiff.vue +1 -1
- package/src/pages-standard/plan-versions/PlanVersionsList.vue +1 -1
- package/src/pages-standard/plan-versions/PlanVersionsMatrix.vue +1 -1
- package/src/pages-standard/plan-versions/PlanVersionsTimeline.vue +1 -1
- package/src/pages-tenant/MySubscriptionBundlesPage.vue +1 -1
- package/src/pages-tenant/OnboardingConfigurator.vue +3 -3
- package/src/pages-tenant/PackageSnapshotPanel.vue +1 -1
- package/src/pages-tenant/PlanChangeWizard.vue +2 -2
- package/src/pages-tenant/TenantPlanSection.vue +3 -3
- package/src/pages-tenant/tenant-plan-section/BundlePreviewDialog.vue +1 -1
- package/src/pages-tenant/tenant-plan-section/TenantBundleStore.vue +2 -2
- package/src/pages-tenant/tenant-plan-section/TenantPlanCardHeader.vue +1 -1
- package/src/pages-tenant/tenant-plan-section/TenantUsageGrid.vue +1 -1
- package/src/quasar/create-super-admin-app.ts +173 -0
- package/src/quasar/index.ts +11 -0
- package/src/quasar/notify.ts +30 -0
- package/src/{manifest-store-factory.ts → vue/manifest-store-factory.ts} +1 -1
- package/src/{platform-loaders.ts → vue/platform-loaders.ts} +4 -4
- package/src/{project-page-host.ts → vue/project-page-host.ts} +1 -1
- package/src/{create-super-admin-app.ts → vue/super-admin-context.ts} +20 -139
- package/src/vue/ui-notify.ts +30 -0
- package/src/{use-actions.ts → vue/use-actions.ts} +1 -1
- package/src/{use-api-list.ts → vue/use-api-list.ts} +1 -1
- package/src/{use-batch-columns.ts → vue/use-batch-columns.ts} +1 -1
- package/src/{use-bulk-publish.ts → vue/use-bulk-publish.ts} +1 -1
- package/src/{use-bundle-versions-map.ts → vue/use-bundle-versions-map.ts} +1 -1
- package/src/{use-bundles.ts → vue/use-bundles.ts} +1 -1
- package/src/{use-business-types.ts → vue/use-business-types.ts} +1 -1
- package/src/{use-catalog-entries.ts → vue/use-catalog-entries.ts} +1 -1
- package/src/{use-discovery.ts → vue/use-discovery.ts} +1 -1
- package/src/{use-entitlement.ts → vue/use-entitlement.ts} +1 -1
- package/src/{use-live-plan-versions.ts → vue/use-live-plan-versions.ts} +1 -1
- package/src/{use-manifest.ts → vue/use-manifest.ts} +1 -1
- package/src/{use-marketing-projections.ts → vue/use-marketing-projections.ts} +1 -1
- package/src/{use-nav.ts → vue/use-nav.ts} +1 -1
- package/src/{use-plans.ts → vue/use-plans.ts} +1 -1
- package/src/{use-promotions.ts → vue/use-promotions.ts} +1 -1
- package/src/{use-public-boot.ts → vue/use-public-boot.ts} +1 -1
- package/src/{use-super-admin-context.ts → vue/use-super-admin-context.ts} +2 -2
- package/src/{use-tenant-action-flow.ts → vue/use-tenant-action-flow.ts} +1 -1
- package/src/{use-tenant-billing-catalog.ts → vue/use-tenant-billing-catalog.ts} +2 -2
- package/src/{use-tenant-billing.ts → vue/use-tenant-billing.ts} +2 -2
- package/src/{use-tenant-manifest.ts → vue/use-tenant-manifest.ts} +1 -1
- package/src/{use-tenant-subscription-bundles.ts → vue/use-tenant-subscription-bundles.ts} +1 -1
- package/dist/testing-e2e/admin-pages-suite.d.cts +0 -37
- package/dist/testing-e2e/admin-pages-suite.d.ts +0 -37
- /package/src/{action-registry.ts → client/action-registry.ts} +0 -0
- /package/src/{batch-column-fetcher.ts → client/batch-column-fetcher.ts} +0 -0
- /package/src/{boot-loader.ts → client/boot-loader.ts} +0 -0
- /package/src/{http-json.ts → client/http-json.ts} +0 -0
- /package/src/{manifest-loader.ts → client/manifest-loader.ts} +0 -0
- /package/src/{nav-builder.ts → client/nav-builder.ts} +0 -0
- /package/src/{plan-versions-catalog.ts → client/plan-versions-catalog.ts} +0 -0
- /package/src/{types.ts → client/types.ts} +0 -0
- /package/src/{version.ts → client/version.ts} +0 -0
- /package/src/{create-admin-routes.ts → vue/create-admin-routes.ts} +0 -0
- /package/src/{entitlement-provider.ts → vue/entitlement-provider.ts} +0 -0
- /package/src/{feature-router-guard.ts → vue/feature-router-guard.ts} +0 -0
- /package/src/{use-audit-entries.ts → vue/use-audit-entries.ts} +0 -0
- /package/src/{use-plan-editor.ts → vue/use-plan-editor.ts} +0 -0
- /package/src/{use-plan-versions.ts → vue/use-plan-versions.ts} +0 -0
- /package/src/{use-platform-tenant-actions.ts → vue/use-platform-tenant-actions.ts} +0 -0
- /package/src/{use-subscription-draft.ts → vue/use-subscription-draft.ts} +0 -0
- /package/src/{use-tenants.ts → vue/use-tenants.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/quasar/index.ts
|
|
21
|
+
var quasar_exports = {};
|
|
22
|
+
__export(quasar_exports, {
|
|
23
|
+
createSuperAdminApp: () => createSuperAdminApp,
|
|
24
|
+
quasarNotify: () => quasarNotify,
|
|
25
|
+
useSuperAdminNotify: () => useSuperAdminNotify
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(quasar_exports);
|
|
28
|
+
|
|
29
|
+
// src/quasar/create-super-admin-app.ts
|
|
30
|
+
var import_vue2 = require("vue");
|
|
31
|
+
var import_quasar2 = require("quasar");
|
|
32
|
+
var import_pinia = require("pinia");
|
|
33
|
+
var import_vue_router = require("vue-router");
|
|
34
|
+
|
|
35
|
+
// src/client/types.ts
|
|
36
|
+
function defaultHttpClient() {
|
|
37
|
+
return (url, init) => fetch(url, init);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/vue/super-admin-context.ts
|
|
41
|
+
var SUPER_ADMIN_BRAND_KEY = /* @__PURE__ */ Symbol.for(
|
|
42
|
+
"@saasicat/ui-vue/SUPER_ADMIN_BRAND"
|
|
43
|
+
);
|
|
44
|
+
var SUPER_ADMIN_ENDPOINTS_KEY = /* @__PURE__ */ Symbol.for(
|
|
45
|
+
"@saasicat/ui-vue/SUPER_ADMIN_ENDPOINTS"
|
|
46
|
+
);
|
|
47
|
+
var SUPER_ADMIN_EXTENSIONS_KEY = /* @__PURE__ */ Symbol.for(
|
|
48
|
+
"@saasicat/ui-vue/SUPER_ADMIN_EXTENSIONS"
|
|
49
|
+
);
|
|
50
|
+
var SUPER_ADMIN_ACTIONS_KEY = /* @__PURE__ */ Symbol.for(
|
|
51
|
+
"@saasicat/ui-vue/SUPER_ADMIN_ACTIONS"
|
|
52
|
+
);
|
|
53
|
+
var SUPER_ADMIN_MANIFEST_KEY = /* @__PURE__ */ Symbol.for(
|
|
54
|
+
"@saasicat/ui-vue/SUPER_ADMIN_MANIFEST"
|
|
55
|
+
);
|
|
56
|
+
var SUPER_ADMIN_LOGIN_ADAPTER_KEY = /* @__PURE__ */ Symbol.for(
|
|
57
|
+
"@saasicat/ui-vue/SUPER_ADMIN_LOGIN_ADAPTER"
|
|
58
|
+
);
|
|
59
|
+
var SUPER_ADMIN_HTTP_KEY = /* @__PURE__ */ Symbol.for(
|
|
60
|
+
"@saasicat/ui-vue/SUPER_ADMIN_HTTP"
|
|
61
|
+
);
|
|
62
|
+
function buildNavigationGuard(options) {
|
|
63
|
+
const { authGuard, manifestGuard } = options;
|
|
64
|
+
if (!authGuard && !manifestGuard) return null;
|
|
65
|
+
return async (to) => {
|
|
66
|
+
if (to.meta?.public === true) return true;
|
|
67
|
+
if (authGuard) {
|
|
68
|
+
if (!authGuard.isAuthenticated()) return authGuard.onUnauthenticated();
|
|
69
|
+
if (authGuard.isSuperAdmin && !authGuard.isSuperAdmin()) {
|
|
70
|
+
return authGuard.onUnauthenticated();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (manifestGuard) {
|
|
74
|
+
try {
|
|
75
|
+
await manifestGuard.ensureLoaded();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
if (manifestGuard.errorRoute && to.path !== manifestGuard.errorRoute) {
|
|
78
|
+
return manifestGuard.errorRoute;
|
|
79
|
+
}
|
|
80
|
+
console.error("[SuperAdmin] manifest load failed", err);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/vue/ui-notify.ts
|
|
88
|
+
var SUPER_ADMIN_NOTIFY_KEY = /* @__PURE__ */ Symbol.for(
|
|
89
|
+
"@saasicat/ui-vue/SUPER_ADMIN_NOTIFY"
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// src/quasar/notify.ts
|
|
93
|
+
var import_vue = require("vue");
|
|
94
|
+
var import_quasar = require("quasar");
|
|
95
|
+
var quasarNotify = (kind, message, options) => {
|
|
96
|
+
import_quasar.Notify.create({
|
|
97
|
+
type: kind,
|
|
98
|
+
message,
|
|
99
|
+
position: "top",
|
|
100
|
+
caption: options?.caption,
|
|
101
|
+
timeout: options?.timeoutMs
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
function useSuperAdminNotify() {
|
|
105
|
+
return (0, import_vue.inject)(SUPER_ADMIN_NOTIFY_KEY, quasarNotify);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/quasar/create-super-admin-app.ts
|
|
109
|
+
var DEFAULT_QUASAR_OPTIONS = {
|
|
110
|
+
plugins: { Notify: import_quasar2.Notify, Dialog: import_quasar2.Dialog, Loading: import_quasar2.Loading },
|
|
111
|
+
config: { notify: { position: "top-right", timeout: 3e3 } }
|
|
112
|
+
};
|
|
113
|
+
function createSuperAdminApp(options) {
|
|
114
|
+
const app = (0, import_vue2.createApp)(options.rootComponent);
|
|
115
|
+
app.use(import_quasar2.Quasar, options.quasarOptions ?? DEFAULT_QUASAR_OPTIONS);
|
|
116
|
+
const pinia = (0, import_pinia.createPinia)();
|
|
117
|
+
app.use(pinia);
|
|
118
|
+
const router = (0, import_vue_router.createRouter)({
|
|
119
|
+
history: options.routerHistory ?? (0, import_vue_router.createWebHistory)(),
|
|
120
|
+
routes: options.appRoutes
|
|
121
|
+
});
|
|
122
|
+
const navGuard = buildNavigationGuard(options);
|
|
123
|
+
if (navGuard) {
|
|
124
|
+
router.beforeEach(navGuard);
|
|
125
|
+
}
|
|
126
|
+
app.use(router);
|
|
127
|
+
const endpoints = {
|
|
128
|
+
apiBase: options.endpoints.apiBase,
|
|
129
|
+
publicBootEndpoint: options.endpoints.publicBootEndpoint ?? `${options.endpoints.apiBase}/boot`,
|
|
130
|
+
manifestEndpoint: options.endpoints.manifestEndpoint ?? `${options.endpoints.apiBase}/manifest`
|
|
131
|
+
};
|
|
132
|
+
app.provide(SUPER_ADMIN_BRAND_KEY, { tag: "SuperAdmin", ...options.brand });
|
|
133
|
+
app.provide(SUPER_ADMIN_ENDPOINTS_KEY, endpoints);
|
|
134
|
+
app.provide(SUPER_ADMIN_EXTENSIONS_KEY, options.extensions ?? {});
|
|
135
|
+
app.provide(SUPER_ADMIN_ACTIONS_KEY, options.actions ?? {});
|
|
136
|
+
app.provide(SUPER_ADMIN_NOTIFY_KEY, options.notify ?? quasarNotify);
|
|
137
|
+
if (options.manifestGuard?.getManifest) {
|
|
138
|
+
app.provide(SUPER_ADMIN_MANIFEST_KEY, options.manifestGuard.getManifest);
|
|
139
|
+
}
|
|
140
|
+
if (options.loginAdapter) {
|
|
141
|
+
app.provide(SUPER_ADMIN_LOGIN_ADAPTER_KEY, options.loginAdapter);
|
|
142
|
+
}
|
|
143
|
+
app.provide(SUPER_ADMIN_HTTP_KEY, options.http ?? defaultHttpClient());
|
|
144
|
+
for (const plugin of options.installPlugins ?? []) {
|
|
145
|
+
plugin(app);
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
app,
|
|
149
|
+
router,
|
|
150
|
+
pinia,
|
|
151
|
+
mount: (selector) => app.mount(selector)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
createSuperAdminApp,
|
|
157
|
+
quasarNotify,
|
|
158
|
+
useSuperAdminNotify
|
|
159
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Component, App } from 'vue';
|
|
2
|
+
import { QuasarPluginOptions } from 'quasar';
|
|
3
|
+
import { Pinia } from 'pinia';
|
|
4
|
+
import { RouteRecordRaw, RouterHistory, Router } from 'vue-router';
|
|
5
|
+
import { H as HttpClient } from '../action-registry-CQ2wL3R-.cjs';
|
|
6
|
+
import { S as SuperAdminGuardOptions, a as SuperAdminBrand, b as SuperAdminEndpoints, E as ExtensionsMap, A as ActionsMap, c as SuperAdminLoginAdapter, U as UiNotify, I as InstallPlugin } from '../ui-notify-D_eAAwRh.cjs';
|
|
7
|
+
import '@saasicat/types';
|
|
8
|
+
|
|
9
|
+
interface CreateSuperAdminAppOptions extends SuperAdminGuardOptions {
|
|
10
|
+
/** App root component (`App.vue`). */
|
|
11
|
+
rootComponent: Component;
|
|
12
|
+
/** App branding (logo, name). */
|
|
13
|
+
brand: SuperAdminBrand;
|
|
14
|
+
/** Endpoint configuration. */
|
|
15
|
+
endpoints: SuperAdminEndpoints;
|
|
16
|
+
/** App's own routes (login, standard pages, bundle pages, …). */
|
|
17
|
+
appRoutes: RouteRecordRaw[];
|
|
18
|
+
/**
|
|
19
|
+
* Static `extensions:` map. Manifest `projectPages[].componentKey` is
|
|
20
|
+
* looked up in it (see Spec §4.4).
|
|
21
|
+
*/
|
|
22
|
+
extensions?: ExtensionsMap;
|
|
23
|
+
/**
|
|
24
|
+
* Static `actions:` map. Manifest `tenants.actions[].actionKey` is looked
|
|
25
|
+
* up in it.
|
|
26
|
+
*/
|
|
27
|
+
actions?: ActionsMap;
|
|
28
|
+
/**
|
|
29
|
+
* Optional: login adapter. When set, it is exposed via `provide()` for the
|
|
30
|
+
* shared `<SuperAdminLoginPage>` (from `pages-standard/`) — the app no
|
|
31
|
+
* longer needs to hold its own LoginPage Vue component.
|
|
32
|
+
*/
|
|
33
|
+
loginAdapter?: SuperAdminLoginAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Optional: router history variant, default `createWebHistory()`.
|
|
36
|
+
* Apps with a subpath mount override this.
|
|
37
|
+
*/
|
|
38
|
+
routerHistory?: RouterHistory;
|
|
39
|
+
/**
|
|
40
|
+
* Optional: Quasar configuration. Default loads `Notify`/`Dialog`/`Loading`
|
|
41
|
+
* with the established consumer convention (`top-right`, 3 s).
|
|
42
|
+
*/
|
|
43
|
+
quasarOptions?: Partial<QuasarPluginOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* Optional: notify port for the standard pages' toasts. Default is the
|
|
46
|
+
* Quasar `Notify` implementation — apps with their own notification
|
|
47
|
+
* center replace it here without touching the pages.
|
|
48
|
+
*/
|
|
49
|
+
notify?: UiNotify;
|
|
50
|
+
/**
|
|
51
|
+
* Optional: additional Vue plugins (e.g. an app's own NotificationCenter)
|
|
52
|
+
* that are installed after the platform setup, before the mount.
|
|
53
|
+
*/
|
|
54
|
+
installPlugins?: InstallPlugin[];
|
|
55
|
+
/**
|
|
56
|
+
* Optional: `HttpClient` for all pre-login calls (boot, first-run setup).
|
|
57
|
+
* Default `defaultHttpClient()` (= `fetch`). Consumers pass their own
|
|
58
|
+
* variant through (auth header, baseURL, retry) — it then applies uniformly,
|
|
59
|
+
* including for the setup wizard. Consumed via `useSuperAdminHttp()`.
|
|
60
|
+
*/
|
|
61
|
+
http?: HttpClient;
|
|
62
|
+
}
|
|
63
|
+
interface SuperAdminAppHandle {
|
|
64
|
+
app: App;
|
|
65
|
+
router: Router;
|
|
66
|
+
pinia: Pinia;
|
|
67
|
+
/** Mounts the app on a selector. Returns the root component instance. */
|
|
68
|
+
mount: (selector: string | Element) => ReturnType<App['mount']>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Universal bootstrap function for SuperAdmin apps. Replaces the `main.ts`
|
|
72
|
+
* boilerplate duplicated per app today (Quasar + Pinia + Router + manifest
|
|
73
|
+
* guard) and exposes the platform maps via `provide()` for downstream
|
|
74
|
+
* components.
|
|
75
|
+
*/
|
|
76
|
+
declare function createSuperAdminApp(options: CreateSuperAdminAppOptions): SuperAdminAppHandle;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Quasar-backed notify port: `position: 'top'` matches the convention the
|
|
80
|
+
* standard pages used with their previous direct `$q.notify` calls.
|
|
81
|
+
*/
|
|
82
|
+
declare const quasarNotify: UiNotify;
|
|
83
|
+
/** Returns the app-provided notify port, falling back to the Quasar default. */
|
|
84
|
+
declare function useSuperAdminNotify(): UiNotify;
|
|
85
|
+
|
|
86
|
+
export { type CreateSuperAdminAppOptions, type SuperAdminAppHandle, createSuperAdminApp, quasarNotify, useSuperAdminNotify };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Component, App } from 'vue';
|
|
2
|
+
import { QuasarPluginOptions } from 'quasar';
|
|
3
|
+
import { Pinia } from 'pinia';
|
|
4
|
+
import { RouteRecordRaw, RouterHistory, Router } from 'vue-router';
|
|
5
|
+
import { H as HttpClient } from '../action-registry-CQ2wL3R-.js';
|
|
6
|
+
import { S as SuperAdminGuardOptions, a as SuperAdminBrand, b as SuperAdminEndpoints, E as ExtensionsMap, A as ActionsMap, c as SuperAdminLoginAdapter, U as UiNotify, I as InstallPlugin } from '../ui-notify-COUzXEQ4.js';
|
|
7
|
+
import '@saasicat/types';
|
|
8
|
+
|
|
9
|
+
interface CreateSuperAdminAppOptions extends SuperAdminGuardOptions {
|
|
10
|
+
/** App root component (`App.vue`). */
|
|
11
|
+
rootComponent: Component;
|
|
12
|
+
/** App branding (logo, name). */
|
|
13
|
+
brand: SuperAdminBrand;
|
|
14
|
+
/** Endpoint configuration. */
|
|
15
|
+
endpoints: SuperAdminEndpoints;
|
|
16
|
+
/** App's own routes (login, standard pages, bundle pages, …). */
|
|
17
|
+
appRoutes: RouteRecordRaw[];
|
|
18
|
+
/**
|
|
19
|
+
* Static `extensions:` map. Manifest `projectPages[].componentKey` is
|
|
20
|
+
* looked up in it (see Spec §4.4).
|
|
21
|
+
*/
|
|
22
|
+
extensions?: ExtensionsMap;
|
|
23
|
+
/**
|
|
24
|
+
* Static `actions:` map. Manifest `tenants.actions[].actionKey` is looked
|
|
25
|
+
* up in it.
|
|
26
|
+
*/
|
|
27
|
+
actions?: ActionsMap;
|
|
28
|
+
/**
|
|
29
|
+
* Optional: login adapter. When set, it is exposed via `provide()` for the
|
|
30
|
+
* shared `<SuperAdminLoginPage>` (from `pages-standard/`) — the app no
|
|
31
|
+
* longer needs to hold its own LoginPage Vue component.
|
|
32
|
+
*/
|
|
33
|
+
loginAdapter?: SuperAdminLoginAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Optional: router history variant, default `createWebHistory()`.
|
|
36
|
+
* Apps with a subpath mount override this.
|
|
37
|
+
*/
|
|
38
|
+
routerHistory?: RouterHistory;
|
|
39
|
+
/**
|
|
40
|
+
* Optional: Quasar configuration. Default loads `Notify`/`Dialog`/`Loading`
|
|
41
|
+
* with the established consumer convention (`top-right`, 3 s).
|
|
42
|
+
*/
|
|
43
|
+
quasarOptions?: Partial<QuasarPluginOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* Optional: notify port for the standard pages' toasts. Default is the
|
|
46
|
+
* Quasar `Notify` implementation — apps with their own notification
|
|
47
|
+
* center replace it here without touching the pages.
|
|
48
|
+
*/
|
|
49
|
+
notify?: UiNotify;
|
|
50
|
+
/**
|
|
51
|
+
* Optional: additional Vue plugins (e.g. an app's own NotificationCenter)
|
|
52
|
+
* that are installed after the platform setup, before the mount.
|
|
53
|
+
*/
|
|
54
|
+
installPlugins?: InstallPlugin[];
|
|
55
|
+
/**
|
|
56
|
+
* Optional: `HttpClient` for all pre-login calls (boot, first-run setup).
|
|
57
|
+
* Default `defaultHttpClient()` (= `fetch`). Consumers pass their own
|
|
58
|
+
* variant through (auth header, baseURL, retry) — it then applies uniformly,
|
|
59
|
+
* including for the setup wizard. Consumed via `useSuperAdminHttp()`.
|
|
60
|
+
*/
|
|
61
|
+
http?: HttpClient;
|
|
62
|
+
}
|
|
63
|
+
interface SuperAdminAppHandle {
|
|
64
|
+
app: App;
|
|
65
|
+
router: Router;
|
|
66
|
+
pinia: Pinia;
|
|
67
|
+
/** Mounts the app on a selector. Returns the root component instance. */
|
|
68
|
+
mount: (selector: string | Element) => ReturnType<App['mount']>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Universal bootstrap function for SuperAdmin apps. Replaces the `main.ts`
|
|
72
|
+
* boilerplate duplicated per app today (Quasar + Pinia + Router + manifest
|
|
73
|
+
* guard) and exposes the platform maps via `provide()` for downstream
|
|
74
|
+
* components.
|
|
75
|
+
*/
|
|
76
|
+
declare function createSuperAdminApp(options: CreateSuperAdminAppOptions): SuperAdminAppHandle;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Quasar-backed notify port: `position: 'top'` matches the convention the
|
|
80
|
+
* standard pages used with their previous direct `$q.notify` calls.
|
|
81
|
+
*/
|
|
82
|
+
declare const quasarNotify: UiNotify;
|
|
83
|
+
/** Returns the app-provided notify port, falling back to the Quasar default. */
|
|
84
|
+
declare function useSuperAdminNotify(): UiNotify;
|
|
85
|
+
|
|
86
|
+
export { type CreateSuperAdminAppOptions, type SuperAdminAppHandle, createSuperAdminApp, quasarNotify, useSuperAdminNotify };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SUPER_ADMIN_ACTIONS_KEY,
|
|
3
|
+
SUPER_ADMIN_BRAND_KEY,
|
|
4
|
+
SUPER_ADMIN_ENDPOINTS_KEY,
|
|
5
|
+
SUPER_ADMIN_EXTENSIONS_KEY,
|
|
6
|
+
SUPER_ADMIN_HTTP_KEY,
|
|
7
|
+
SUPER_ADMIN_LOGIN_ADAPTER_KEY,
|
|
8
|
+
SUPER_ADMIN_MANIFEST_KEY,
|
|
9
|
+
SUPER_ADMIN_NOTIFY_KEY,
|
|
10
|
+
buildNavigationGuard
|
|
11
|
+
} from "../chunk-3YP2ZAOD.js";
|
|
12
|
+
import {
|
|
13
|
+
defaultHttpClient
|
|
14
|
+
} from "../chunk-LVGUSD3T.js";
|
|
15
|
+
|
|
16
|
+
// src/quasar/create-super-admin-app.ts
|
|
17
|
+
import { createApp } from "vue";
|
|
18
|
+
import { Quasar, Notify as Notify2, Dialog, Loading } from "quasar";
|
|
19
|
+
import { createPinia } from "pinia";
|
|
20
|
+
import {
|
|
21
|
+
createRouter,
|
|
22
|
+
createWebHistory
|
|
23
|
+
} from "vue-router";
|
|
24
|
+
|
|
25
|
+
// src/quasar/notify.ts
|
|
26
|
+
import { inject } from "vue";
|
|
27
|
+
import { Notify } from "quasar";
|
|
28
|
+
var quasarNotify = (kind, message, options) => {
|
|
29
|
+
Notify.create({
|
|
30
|
+
type: kind,
|
|
31
|
+
message,
|
|
32
|
+
position: "top",
|
|
33
|
+
caption: options?.caption,
|
|
34
|
+
timeout: options?.timeoutMs
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
function useSuperAdminNotify() {
|
|
38
|
+
return inject(SUPER_ADMIN_NOTIFY_KEY, quasarNotify);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/quasar/create-super-admin-app.ts
|
|
42
|
+
var DEFAULT_QUASAR_OPTIONS = {
|
|
43
|
+
plugins: { Notify: Notify2, Dialog, Loading },
|
|
44
|
+
config: { notify: { position: "top-right", timeout: 3e3 } }
|
|
45
|
+
};
|
|
46
|
+
function createSuperAdminApp(options) {
|
|
47
|
+
const app = createApp(options.rootComponent);
|
|
48
|
+
app.use(Quasar, options.quasarOptions ?? DEFAULT_QUASAR_OPTIONS);
|
|
49
|
+
const pinia = createPinia();
|
|
50
|
+
app.use(pinia);
|
|
51
|
+
const router = createRouter({
|
|
52
|
+
history: options.routerHistory ?? createWebHistory(),
|
|
53
|
+
routes: options.appRoutes
|
|
54
|
+
});
|
|
55
|
+
const navGuard = buildNavigationGuard(options);
|
|
56
|
+
if (navGuard) {
|
|
57
|
+
router.beforeEach(navGuard);
|
|
58
|
+
}
|
|
59
|
+
app.use(router);
|
|
60
|
+
const endpoints = {
|
|
61
|
+
apiBase: options.endpoints.apiBase,
|
|
62
|
+
publicBootEndpoint: options.endpoints.publicBootEndpoint ?? `${options.endpoints.apiBase}/boot`,
|
|
63
|
+
manifestEndpoint: options.endpoints.manifestEndpoint ?? `${options.endpoints.apiBase}/manifest`
|
|
64
|
+
};
|
|
65
|
+
app.provide(SUPER_ADMIN_BRAND_KEY, { tag: "SuperAdmin", ...options.brand });
|
|
66
|
+
app.provide(SUPER_ADMIN_ENDPOINTS_KEY, endpoints);
|
|
67
|
+
app.provide(SUPER_ADMIN_EXTENSIONS_KEY, options.extensions ?? {});
|
|
68
|
+
app.provide(SUPER_ADMIN_ACTIONS_KEY, options.actions ?? {});
|
|
69
|
+
app.provide(SUPER_ADMIN_NOTIFY_KEY, options.notify ?? quasarNotify);
|
|
70
|
+
if (options.manifestGuard?.getManifest) {
|
|
71
|
+
app.provide(SUPER_ADMIN_MANIFEST_KEY, options.manifestGuard.getManifest);
|
|
72
|
+
}
|
|
73
|
+
if (options.loginAdapter) {
|
|
74
|
+
app.provide(SUPER_ADMIN_LOGIN_ADAPTER_KEY, options.loginAdapter);
|
|
75
|
+
}
|
|
76
|
+
app.provide(SUPER_ADMIN_HTTP_KEY, options.http ?? defaultHttpClient());
|
|
77
|
+
for (const plugin of options.installPlugins ?? []) {
|
|
78
|
+
plugin(app);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
app,
|
|
82
|
+
router,
|
|
83
|
+
pinia,
|
|
84
|
+
mount: (selector) => app.mount(selector)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
createSuperAdminApp,
|
|
89
|
+
quasarNotify,
|
|
90
|
+
useSuperAdminNotify
|
|
91
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Component, App, InjectionKey } from 'vue';
|
|
2
|
+
import { NavigationGuardWithThis } from 'vue-router';
|
|
3
|
+
import { ActionKey, ComponentKey, AdminManifest } from '@saasicat/types';
|
|
4
|
+
import { A as ActionHandler, H as HttpClient } from './action-registry-CQ2wL3R-.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* App-specific branding data that the platform `AdminLayout` and other
|
|
8
|
+
* consumers read via `useSuperAdminBrand()`.
|
|
9
|
+
*/
|
|
10
|
+
interface SuperAdminBrand {
|
|
11
|
+
/** 2-letter abbreviation in the logo badge (`'ma'`, `'da'`, …). */
|
|
12
|
+
logoText: string;
|
|
13
|
+
/** Full display name (`'DemoApp'`, `'ClubApp'`, …). */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Optional: tag to the right of the name, default `'SuperAdmin'`. */
|
|
16
|
+
tag?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Endpoint configuration. `apiBase` is the shared prefix under which
|
|
20
|
+
* `/manifest`, `/boot` and extra routes live.
|
|
21
|
+
*/
|
|
22
|
+
interface SuperAdminEndpoints {
|
|
23
|
+
/** Shared prefix, e.g. `'/api/admin'` or `'/api/v1/admin'`. */
|
|
24
|
+
apiBase: string;
|
|
25
|
+
/** Pre-login branding endpoint, default `${apiBase}/boot`. */
|
|
26
|
+
publicBootEndpoint?: string;
|
|
27
|
+
/** Post-login full-manifest endpoint, default `${apiBase}/manifest`. */
|
|
28
|
+
manifestEndpoint?: string;
|
|
29
|
+
}
|
|
30
|
+
type ExtensionLoader = () => Promise<Component | {
|
|
31
|
+
default: Component;
|
|
32
|
+
}>;
|
|
33
|
+
type ExtensionsMap = Record<ComponentKey, ExtensionLoader>;
|
|
34
|
+
type ActionsMap = Record<ActionKey, ActionHandler>;
|
|
35
|
+
interface SuperAdminAuthGuardOptions {
|
|
36
|
+
/** App provides: is the user currently logged in? */
|
|
37
|
+
isAuthenticated: () => boolean;
|
|
38
|
+
/** App provides: does the user have the SuperAdmin role? Default: only check `isAuthenticated`. */
|
|
39
|
+
isSuperAdmin?: () => boolean;
|
|
40
|
+
/** App provides: redirect path for unauthenticated calls (e.g. `'/login'`). */
|
|
41
|
+
onUnauthenticated: () => string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of a login attempt. Apps pass this back from their auth store to the
|
|
45
|
+
* platform LoginPage; the page renders an appropriate error message.
|
|
46
|
+
*
|
|
47
|
+
* `ok: true` → login succeeded, page redirects to `redirectAfterLogin`.
|
|
48
|
+
* `ok: false` → page shows `message` or a translation derived from `code`.
|
|
49
|
+
*
|
|
50
|
+
* Known codes:
|
|
51
|
+
* - `BAD_CREDENTIALS` — wrong email/password combination.
|
|
52
|
+
* - `NOT_SUPER_ADMIN` — account does not have the SuperAdmin role.
|
|
53
|
+
* - otherwise — app-specific; `message` is displayed directly.
|
|
54
|
+
*/
|
|
55
|
+
type SuperAdminLoginResult = {
|
|
56
|
+
ok: true;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
code?: 'BAD_CREDENTIALS' | 'NOT_SUPER_ADMIN' | string;
|
|
60
|
+
message?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Login adapter. The app passes its auth-store call through here. The platform
|
|
64
|
+
* LoginPage consumes it via `useSuperAdminLoginAdapter()`, without knowledge
|
|
65
|
+
* of app-specific stores (Pinia, auth API routes, MFA hooks).
|
|
66
|
+
*/
|
|
67
|
+
interface SuperAdminLoginAdapter {
|
|
68
|
+
/**
|
|
69
|
+
* Performs the login. The app store encapsulates the API call, token
|
|
70
|
+
* storage, MFA hops etc.
|
|
71
|
+
*/
|
|
72
|
+
login(email: string, password: string): Promise<SuperAdminLoginResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Target route after a successful login. Default: `/admin/dashboard`
|
|
75
|
+
* (platform convention for the standard pages — apps with a different
|
|
76
|
+
* default mount override this here).
|
|
77
|
+
*/
|
|
78
|
+
redirectAfterLogin?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Optional: dev hint (test account), shown below the form. Deliberately
|
|
81
|
+
* rendered only when `environment !== 'production'`.
|
|
82
|
+
*/
|
|
83
|
+
devHint?: {
|
|
84
|
+
email: string;
|
|
85
|
+
password: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
interface SuperAdminManifestGuardOptions {
|
|
89
|
+
/**
|
|
90
|
+
* App provides: loads the manifest into the app store. The router guard
|
|
91
|
+
* `await`s the promise before the route is resolved.
|
|
92
|
+
*
|
|
93
|
+
* **On loader error:** the promise REJECTS. The router guard catches the
|
|
94
|
+
* rejection and decides depending on `errorRoute`:
|
|
95
|
+
* - `errorRoute` set → redirect to this route (fail-closed).
|
|
96
|
+
* - `errorRoute` not set → `console.error` + render allowed
|
|
97
|
+
* (defensive default behavior; the app must render the manifest gap
|
|
98
|
+
* itself).
|
|
99
|
+
*/
|
|
100
|
+
ensureLoaded: () => Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Optional: read accessor on the loaded manifest. When set, it is exposed
|
|
103
|
+
* via `provide(SUPER_ADMIN_MANIFEST_KEY)` — the `<ProjectPageHost>`
|
|
104
|
+
* resolves manifest `projectPages` through it against the
|
|
105
|
+
* `extensions:` map.
|
|
106
|
+
*/
|
|
107
|
+
getManifest?: () => AdminManifest | null;
|
|
108
|
+
/**
|
|
109
|
+
* Optional: path that the router guard redirects to on a manifest load
|
|
110
|
+
* error (fail-closed mode). The app must register the route in `appRoutes`
|
|
111
|
+
* and mark it as `meta.public = true`, otherwise it runs through the
|
|
112
|
+
* manifest guard again and produces a redirect loop.
|
|
113
|
+
*/
|
|
114
|
+
errorRoute?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Guard configuration shared by `buildNavigationGuard()` and
|
|
118
|
+
* `createSuperAdminApp()` (which embeds both fields in its options).
|
|
119
|
+
*/
|
|
120
|
+
interface SuperAdminGuardOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Optional: auth guard. When set, `router.beforeEach` is wired up
|
|
123
|
+
* automatically — `to.meta.public === true` bypasses the guard.
|
|
124
|
+
*/
|
|
125
|
+
authGuard?: SuperAdminAuthGuardOptions;
|
|
126
|
+
/**
|
|
127
|
+
* Optional: manifest guard. Runs after a successful auth guard, blocks the
|
|
128
|
+
* render until the manifest is loaded (prevents sidebar flicker).
|
|
129
|
+
*/
|
|
130
|
+
manifestGuard?: SuperAdminManifestGuardOptions;
|
|
131
|
+
}
|
|
132
|
+
/** Vue inject key for `useSuperAdminBrand()`. */
|
|
133
|
+
declare const SUPER_ADMIN_BRAND_KEY: InjectionKey<SuperAdminBrand>;
|
|
134
|
+
/** Vue inject key for `useSuperAdminEndpoints()`. */
|
|
135
|
+
declare const SUPER_ADMIN_ENDPOINTS_KEY: InjectionKey<Required<SuperAdminEndpoints>>;
|
|
136
|
+
/** Vue inject key for `useSuperAdminExtensions()`. */
|
|
137
|
+
declare const SUPER_ADMIN_EXTENSIONS_KEY: InjectionKey<ExtensionsMap>;
|
|
138
|
+
/** Vue inject key for `useSuperAdminActions()`. */
|
|
139
|
+
declare const SUPER_ADMIN_ACTIONS_KEY: InjectionKey<ActionsMap>;
|
|
140
|
+
/**
|
|
141
|
+
* Vue inject key for the manifest accessor. Only provided when
|
|
142
|
+
* `manifestGuard.getManifest` was passed to `createSuperAdminApp()` — the
|
|
143
|
+
* `<ProjectPageHost>` needs it to resolve project pages.
|
|
144
|
+
*/
|
|
145
|
+
declare const SUPER_ADMIN_MANIFEST_KEY: InjectionKey<() => AdminManifest | null>;
|
|
146
|
+
/** Vue inject key for `useSuperAdminLoginAdapter()`. */
|
|
147
|
+
declare const SUPER_ADMIN_LOGIN_ADAPTER_KEY: InjectionKey<SuperAdminLoginAdapter>;
|
|
148
|
+
/** Vue inject key for `useSuperAdminHttp()` (pre-login HttpClient). */
|
|
149
|
+
declare const SUPER_ADMIN_HTTP_KEY: InjectionKey<HttpClient>;
|
|
150
|
+
/**
|
|
151
|
+
* Additional Vue plugins (e.g. an app's own NotificationCenter) that a
|
|
152
|
+
* bootstrap installs after the platform setup, before the mount.
|
|
153
|
+
*/
|
|
154
|
+
type InstallPlugin = (app: App) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Internal helper, exported for isolated unit tests of the navigation
|
|
157
|
+
* behavior (auth redirect, manifest fail-closed path). Consumers should call
|
|
158
|
+
* `createSuperAdminApp()`, not this helper directly.
|
|
159
|
+
*/
|
|
160
|
+
declare function buildNavigationGuard(options: SuperAdminGuardOptions): NavigationGuardWithThis<undefined> | null;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Feedback kind, aligned with the established page conventions
|
|
164
|
+
* (`positive` = success, `negative` = error).
|
|
165
|
+
*/
|
|
166
|
+
type UiNotifyKind = 'positive' | 'negative' | 'warning' | 'info';
|
|
167
|
+
interface UiNotifyOptions {
|
|
168
|
+
/** Secondary line below the message (e.g. changed fields, one-time password). */
|
|
169
|
+
caption?: string;
|
|
170
|
+
/** Display duration in ms; implementations fall back to their default when unset. */
|
|
171
|
+
timeoutMs?: number;
|
|
172
|
+
}
|
|
173
|
+
/** Notify port. Compatible with the `(kind, message)` callbacks pages already accept. */
|
|
174
|
+
type UiNotify = (kind: UiNotifyKind, message: string, options?: UiNotifyOptions) => void;
|
|
175
|
+
/** Vue inject key for the notify port (see `Symbol.for` note in super-admin-context.ts). */
|
|
176
|
+
declare const SUPER_ADMIN_NOTIFY_KEY: InjectionKey<UiNotify>;
|
|
177
|
+
|
|
178
|
+
export { type ActionsMap as A, type ExtensionsMap as E, type InstallPlugin as I, type SuperAdminGuardOptions as S, type UiNotify as U, type SuperAdminBrand as a, type SuperAdminEndpoints as b, type SuperAdminLoginAdapter as c, type ExtensionLoader as d, SUPER_ADMIN_ACTIONS_KEY as e, SUPER_ADMIN_BRAND_KEY as f, SUPER_ADMIN_ENDPOINTS_KEY as g, SUPER_ADMIN_EXTENSIONS_KEY as h, SUPER_ADMIN_HTTP_KEY as i, SUPER_ADMIN_LOGIN_ADAPTER_KEY as j, SUPER_ADMIN_MANIFEST_KEY as k, SUPER_ADMIN_NOTIFY_KEY as l, type SuperAdminAuthGuardOptions as m, type SuperAdminLoginResult as n, type SuperAdminManifestGuardOptions as o, type UiNotifyKind as p, type UiNotifyOptions as q, buildNavigationGuard as r };
|