@managespace/sdk 0.1.183 → 0.1.184
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/dist/extensibility/functions/project/communication-method.d.ts +4 -2
- package/dist/extensibility/functions/project/communication-method.d.ts.map +1 -1
- package/dist/generated/apis/default-api.d.ts +9 -0
- package/dist/generated/apis/default-api.d.ts.map +1 -1
- package/dist/generated/apis/default-api.js +29 -0
- package/dist/generated/models/send-email.d.ts +2 -2
- package/dist/generated/models/send-email.d.ts.map +1 -1
- package/dist/generated/models/send-email.js +2 -2
- package/dist/generated/models/site.d.ts +6 -0
- package/dist/generated/models/site.d.ts.map +1 -1
- package/dist/generated/models/site.js +4 -0
- package/package.deploy.json +4 -8
- package/package.json +3 -4
- package/src/extensibility/functions/project/communication-method.ts +9 -2
- package/src/generated/apis/default-api.ts +43 -0
- package/src/generated/models/send-email.ts +4 -4
- package/src/generated/models/site.ts +9 -0
- package/dist/extensions/host-bridge.d.ts +0 -166
- package/dist/extensions/host-bridge.d.ts.map +0 -1
- package/dist/extensions/host-bridge.js +0 -259
- package/dist/extensions/index.d.ts +0 -40
- package/dist/extensions/index.d.ts.map +0 -1
- package/dist/extensions/index.js +0 -55
- package/dist/extensions/types.d.ts +0 -111
- package/dist/extensions/types.d.ts.map +0 -1
- package/dist/extensions/types.js +0 -2
- package/dist/generated/apis/extensions-api.d.ts +0 -98
- package/dist/generated/apis/extensions-api.d.ts.map +0 -1
- package/dist/generated/apis/extensions-api.js +0 -295
- package/dist/generated/models/extension-org.d.ts +0 -64
- package/dist/generated/models/extension-org.d.ts.map +0 -1
- package/dist/generated/models/extension-org.js +0 -70
- package/dist/generated/models/extension.d.ts +0 -106
- package/dist/generated/models/extension.d.ts.map +0 -1
- package/dist/generated/models/extension.js +0 -98
- package/dist/generated/models/update-document-type.d.ts +0 -43
- package/dist/generated/models/update-document-type.d.ts.map +0 -1
- package/dist/generated/models/update-document-type.js +0 -61
|
@@ -8,10 +8,17 @@ export namespace CommunicationMethod {
|
|
|
8
8
|
export class SendEmail implements ExtPlugin {
|
|
9
9
|
responseType!: Omit<
|
|
10
10
|
SendEmailPayload,
|
|
11
|
-
|
|
11
|
+
| 'receiverEmail'
|
|
12
|
+
| 'senderEmail'
|
|
13
|
+
| 'contactId'
|
|
14
|
+
| 'customerId'
|
|
15
|
+
| 'documentIds'
|
|
12
16
|
>;
|
|
13
17
|
|
|
14
|
-
payload!: Omit<
|
|
18
|
+
payload!: Omit<
|
|
19
|
+
SendEmailPayload,
|
|
20
|
+
'customerId' | 'contactId' | 'documentIds'
|
|
21
|
+
> & { attachmentUrls?: string[] };
|
|
15
22
|
}
|
|
16
23
|
export class SendSms implements ExtPlugin {
|
|
17
24
|
responseType!: Omit<
|
|
@@ -681,6 +681,10 @@ export interface CancelSubscriptionRequest {
|
|
|
681
681
|
cancelSubscription: CancelSubscription;
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
+
export interface CompleteOnboardRequest {
|
|
685
|
+
siteId: string;
|
|
686
|
+
}
|
|
687
|
+
|
|
684
688
|
export interface CreateAssetRequest {
|
|
685
689
|
siteId: string;
|
|
686
690
|
createAssetCustom: CreateAssetCustom;
|
|
@@ -1966,6 +1970,45 @@ export class DefaultApi extends runtime.BaseAPI {
|
|
|
1966
1970
|
return await response.value();
|
|
1967
1971
|
}
|
|
1968
1972
|
|
|
1973
|
+
/**
|
|
1974
|
+
*/
|
|
1975
|
+
async completeOnboardRaw(requestParameters: CompleteOnboardRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Site>> {
|
|
1976
|
+
if (requestParameters['siteId'] == null) {
|
|
1977
|
+
throw new runtime.RequiredError(
|
|
1978
|
+
'siteId',
|
|
1979
|
+
'Required parameter "siteId" was null or undefined when calling completeOnboard().'
|
|
1980
|
+
);
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
const queryParameters: any = {};
|
|
1984
|
+
|
|
1985
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
1986
|
+
|
|
1987
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
1988
|
+
const token = this.configuration.accessToken;
|
|
1989
|
+
const tokenString = await token("bearer", []);
|
|
1990
|
+
|
|
1991
|
+
if (tokenString) {
|
|
1992
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
const response = await this.request({
|
|
1996
|
+
path: `/api/org/sites/{siteId}/complete-onboard`.replace(`{${"siteId"}}`, encodeURIComponent(String(requestParameters['siteId']))),
|
|
1997
|
+
method: 'POST',
|
|
1998
|
+
headers: headerParameters,
|
|
1999
|
+
query: queryParameters,
|
|
2000
|
+
}, initOverrides);
|
|
2001
|
+
|
|
2002
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => SiteFromJSON(jsonValue));
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
*/
|
|
2007
|
+
async completeOnboard(requestParameters: CompleteOnboardRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Site> {
|
|
2008
|
+
const response = await this.completeOnboardRaw(requestParameters, initOverrides);
|
|
2009
|
+
return await response.value();
|
|
2010
|
+
}
|
|
2011
|
+
|
|
1969
2012
|
/**
|
|
1970
2013
|
*/
|
|
1971
2014
|
async createAssetRaw(requestParameters: CreateAssetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Asset>> {
|
|
@@ -63,11 +63,11 @@ export interface SendEmail {
|
|
|
63
63
|
*/
|
|
64
64
|
html?: string;
|
|
65
65
|
/**
|
|
66
|
-
* The
|
|
66
|
+
* The IDs of documents to attach to the email.
|
|
67
67
|
* @type {Array<string>}
|
|
68
68
|
* @memberof SendEmail
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
documentIds?: Array<string>;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -99,7 +99,7 @@ export function SendEmailFromJSONTyped(json: any, ignoreDiscriminator: boolean):
|
|
|
99
99
|
'subject': json['subject'],
|
|
100
100
|
'text': json['text'] == null ? undefined : json['text'],
|
|
101
101
|
'html': json['html'] == null ? undefined : json['html'],
|
|
102
|
-
'
|
|
102
|
+
'documentIds': json['documentIds'] == null ? undefined : json['documentIds'],
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -121,7 +121,7 @@ export function SendEmailToJSONTyped(value?: SendEmail | null, ignoreDiscriminat
|
|
|
121
121
|
'subject': value['subject'],
|
|
122
122
|
'text': value['text'],
|
|
123
123
|
'html': value['html'],
|
|
124
|
-
'
|
|
124
|
+
'documentIds': value['documentIds'],
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -309,6 +309,12 @@ export interface Site {
|
|
|
309
309
|
* @memberof Site
|
|
310
310
|
*/
|
|
311
311
|
division: string | null;
|
|
312
|
+
/**
|
|
313
|
+
* When onboarding was completed for this site
|
|
314
|
+
* @type {Date}
|
|
315
|
+
* @memberof Site
|
|
316
|
+
*/
|
|
317
|
+
onboardCompletedAt: Date | null;
|
|
312
318
|
}
|
|
313
319
|
|
|
314
320
|
/**
|
|
@@ -324,6 +330,7 @@ export function instanceOfSite(value: object): value is Site {
|
|
|
324
330
|
if (!('addressId' in value) || value['addressId'] === undefined) return false;
|
|
325
331
|
if (!('siteCode' in value) || value['siteCode'] === undefined) return false;
|
|
326
332
|
if (!('division' in value) || value['division'] === undefined) return false;
|
|
333
|
+
if (!('onboardCompletedAt' in value) || value['onboardCompletedAt'] === undefined) return false;
|
|
327
334
|
return true;
|
|
328
335
|
}
|
|
329
336
|
|
|
@@ -364,6 +371,7 @@ export function SiteFromJSONTyped(json: any, ignoreDiscriminator: boolean): Site
|
|
|
364
371
|
'siteRoles': json['siteRoles'] == null ? undefined : ((json['siteRoles'] as Array<any>).map(SiteRoleFromJSON)),
|
|
365
372
|
'siteCode': json['siteCode'],
|
|
366
373
|
'division': json['division'],
|
|
374
|
+
'onboardCompletedAt': (json['onboardCompletedAt'] == null ? null : new Date(json['onboardCompletedAt'])),
|
|
367
375
|
};
|
|
368
376
|
}
|
|
369
377
|
|
|
@@ -405,6 +413,7 @@ export function SiteToJSONTyped(value?: Site | null, ignoreDiscriminator: boolea
|
|
|
405
413
|
'siteRoles': value['siteRoles'] == null ? undefined : ((value['siteRoles'] as Array<any>).map(SiteRoleToJSON)),
|
|
406
414
|
'siteCode': value['siteCode'],
|
|
407
415
|
'division': value['division'],
|
|
416
|
+
'onboardCompletedAt': (value['onboardCompletedAt'] == null ? null : (value['onboardCompletedAt'] as any).toISOString()),
|
|
408
417
|
};
|
|
409
418
|
}
|
|
410
419
|
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { EntityEventHandler, ExtensionContext } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Get the extension context from the ManageSpace host.
|
|
4
|
-
*
|
|
5
|
-
* This returns a promise that resolves when the context is received from the host.
|
|
6
|
-
* Call this early in your extension's lifecycle to get authentication and org context.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { getContext } from '@managespace/sdk/extensions';
|
|
11
|
-
*
|
|
12
|
-
* const context = await getContext();
|
|
13
|
-
* console.log('Org ID:', context.orgId);
|
|
14
|
-
* console.log('API URL:', context.apiBaseUrl);
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function getContext(): Promise<ExtensionContext>;
|
|
18
|
-
/**
|
|
19
|
-
* Get the current context synchronously.
|
|
20
|
-
*
|
|
21
|
-
* Returns null if the context has not yet been received from the host.
|
|
22
|
-
* Prefer using `getContext()` which waits for the context to be available.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { getCurrentContext } from '@managespace/sdk/extensions';
|
|
27
|
-
*
|
|
28
|
-
* const context = getCurrentContext();
|
|
29
|
-
* if (context) {
|
|
30
|
-
* console.log('Already have context:', context.orgId);
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function getCurrentContext(): ExtensionContext | null;
|
|
35
|
-
/**
|
|
36
|
-
* Navigate the ManageSpace host application to a specific path.
|
|
37
|
-
*
|
|
38
|
-
* Use this to navigate users to pages within ManageSpace, such as
|
|
39
|
-
* customer profiles, asset details, or other views.
|
|
40
|
-
*
|
|
41
|
-
* @param path - The path to navigate to (e.g., "/customer/123")
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* import { navigate } from '@managespace/sdk/extensions';
|
|
46
|
-
*
|
|
47
|
-
* // Navigate to a customer profile
|
|
48
|
-
* navigate('/customer/abc-123');
|
|
49
|
-
*
|
|
50
|
-
* // Navigate to the assets page
|
|
51
|
-
* navigate('/assets');
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare function navigate(path: string): void;
|
|
55
|
-
/**
|
|
56
|
-
* Show a toast notification in the ManageSpace host application.
|
|
57
|
-
*
|
|
58
|
-
* Use this for user feedback after actions complete.
|
|
59
|
-
*
|
|
60
|
-
* @param message - The message to display
|
|
61
|
-
* @param variant - The toast type: 'success' or 'error' (default: 'success')
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { showToast } from '@managespace/sdk/extensions';
|
|
66
|
-
*
|
|
67
|
-
* // Success notification
|
|
68
|
-
* showToast('Customer updated successfully');
|
|
69
|
-
*
|
|
70
|
-
* // Error notification
|
|
71
|
-
* showToast('Failed to save changes', 'error');
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function showToast(message: string, variant?: 'success' | 'error'): void;
|
|
75
|
-
/**
|
|
76
|
-
* Signal to the ManageSpace host that the extension is ready to receive context.
|
|
77
|
-
*
|
|
78
|
-
* Call this after your extension has loaded and set up its message listeners.
|
|
79
|
-
* The host will respond with a CONTEXT_INIT message containing the ExtensionContext.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* import { signalReady, getContext } from '@managespace/sdk/extensions';
|
|
84
|
-
*
|
|
85
|
-
* // Signal ready and wait for context
|
|
86
|
-
* signalReady();
|
|
87
|
-
* const context = await getContext();
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export declare function signalReady(): void;
|
|
91
|
-
/**
|
|
92
|
-
* Subscribe to entity events from the ManageSpace host.
|
|
93
|
-
*
|
|
94
|
-
* The host sends events when entities (customers, assets, etc.) are
|
|
95
|
-
* created, updated, or deleted. Use this to keep your extension in sync.
|
|
96
|
-
*
|
|
97
|
-
* @param handler - Callback function to handle entity events
|
|
98
|
-
* @returns Unsubscribe function to remove the handler
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* import { onEntityEvent } from '@managespace/sdk/extensions';
|
|
103
|
-
*
|
|
104
|
-
* const unsubscribe = onEntityEvent((event) => {
|
|
105
|
-
* if (event.entityType === 'customer' && event.action === 'updated') {
|
|
106
|
-
* console.log('Customer updated:', event.entityId);
|
|
107
|
-
* refreshCustomerData();
|
|
108
|
-
* }
|
|
109
|
-
* });
|
|
110
|
-
*
|
|
111
|
-
* // Later, to stop listening:
|
|
112
|
-
* unsubscribe();
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
export declare function onEntityEvent(handler: EntityEventHandler): () => void;
|
|
116
|
-
/**
|
|
117
|
-
* Create a configured fetch function for calling the ManageSpace API.
|
|
118
|
-
*
|
|
119
|
-
* This returns a fetch wrapper that automatically includes credentials
|
|
120
|
-
* and sets the correct headers for API calls.
|
|
121
|
-
*
|
|
122
|
-
* @param context - The extension context from getContext()
|
|
123
|
-
* @returns A fetch function configured for ManageSpace API calls
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* import { getContext, createApiFetch } from '@managespace/sdk/extensions';
|
|
128
|
-
*
|
|
129
|
-
* const context = await getContext();
|
|
130
|
-
* const apiFetch = createApiFetch(context);
|
|
131
|
-
*
|
|
132
|
-
* // Fetch customers
|
|
133
|
-
* const response = await apiFetch('/api/crm/customers/queries', {
|
|
134
|
-
* method: 'POST',
|
|
135
|
-
* body: JSON.stringify({
|
|
136
|
-
* pageOptions: { offset: 0, limit: 20 }
|
|
137
|
-
* })
|
|
138
|
-
* });
|
|
139
|
-
* const data = await response.json();
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
export declare function createApiFetch(context: ExtensionContext): (path: string, options?: RequestInit) => Promise<Response>;
|
|
143
|
-
/**
|
|
144
|
-
* Create a configured fetch function for calling your extension's BFF.
|
|
145
|
-
*
|
|
146
|
-
* This returns a fetch wrapper that forwards credentials to your BFF,
|
|
147
|
-
* allowing it to make authenticated calls to the ManageSpace API.
|
|
148
|
-
*
|
|
149
|
-
* @param context - The extension context from getContext()
|
|
150
|
-
* @returns A fetch function configured for BFF calls, or null if no BFF is configured
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```typescript
|
|
154
|
-
* import { getContext, createBffFetch } from '@managespace/sdk/extensions';
|
|
155
|
-
*
|
|
156
|
-
* const context = await getContext();
|
|
157
|
-
* const bffFetch = createBffFetch(context);
|
|
158
|
-
*
|
|
159
|
-
* if (bffFetch) {
|
|
160
|
-
* const response = await bffFetch('/api/enriched-customers');
|
|
161
|
-
* const data = await response.json();
|
|
162
|
-
* }
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
export declare function createBffFetch(context: ExtensionContext): ((path: string, options?: RequestInit) => Promise<Response>) | null;
|
|
166
|
-
//# sourceMappingURL=host-bridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-bridge.d.ts","sourceRoot":"","sources":["../../src/extensions/host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EAClB,gBAAgB,EAGnB,MAAM,SAAS,CAAC;AAiCjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAQtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,GAAG,IAAI,CAE3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAM3C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,SAAS,GAAG,OAAmB,GACzC,IAAI,CAMN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAKrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,gBAAgB,GAC1B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAY5D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,gBAAgB,GAC1B,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAgBrE"}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getContext = getContext;
|
|
4
|
-
exports.getCurrentContext = getCurrentContext;
|
|
5
|
-
exports.navigate = navigate;
|
|
6
|
-
exports.showToast = showToast;
|
|
7
|
-
exports.signalReady = signalReady;
|
|
8
|
-
exports.onEntityEvent = onEntityEvent;
|
|
9
|
-
exports.createApiFetch = createApiFetch;
|
|
10
|
-
exports.createBffFetch = createBffFetch;
|
|
11
|
-
let contextResolve = null;
|
|
12
|
-
let currentContext = null;
|
|
13
|
-
const entityEventHandlers = new Set();
|
|
14
|
-
// Set up message listener when this module loads
|
|
15
|
-
if (typeof window !== 'undefined') {
|
|
16
|
-
window.addEventListener('message', (event) => {
|
|
17
|
-
if (!event.data?.type)
|
|
18
|
-
return;
|
|
19
|
-
switch (event.data.type) {
|
|
20
|
-
case 'CONTEXT_INIT':
|
|
21
|
-
currentContext = event.data.payload;
|
|
22
|
-
if (contextResolve) {
|
|
23
|
-
contextResolve(event.data.payload);
|
|
24
|
-
contextResolve = null;
|
|
25
|
-
}
|
|
26
|
-
break;
|
|
27
|
-
case 'ENTITY_EVENT':
|
|
28
|
-
for (const handler of entityEventHandlers) {
|
|
29
|
-
try {
|
|
30
|
-
handler(event.data.payload);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error('Entity event handler error:', error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get the extension context from the ManageSpace host.
|
|
42
|
-
*
|
|
43
|
-
* This returns a promise that resolves when the context is received from the host.
|
|
44
|
-
* Call this early in your extension's lifecycle to get authentication and org context.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* import { getContext } from '@managespace/sdk/extensions';
|
|
49
|
-
*
|
|
50
|
-
* const context = await getContext();
|
|
51
|
-
* console.log('Org ID:', context.orgId);
|
|
52
|
-
* console.log('API URL:', context.apiBaseUrl);
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
function getContext() {
|
|
56
|
-
if (currentContext) {
|
|
57
|
-
return Promise.resolve(currentContext);
|
|
58
|
-
}
|
|
59
|
-
return new Promise((resolve) => {
|
|
60
|
-
contextResolve = resolve;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get the current context synchronously.
|
|
65
|
-
*
|
|
66
|
-
* Returns null if the context has not yet been received from the host.
|
|
67
|
-
* Prefer using `getContext()` which waits for the context to be available.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* import { getCurrentContext } from '@managespace/sdk/extensions';
|
|
72
|
-
*
|
|
73
|
-
* const context = getCurrentContext();
|
|
74
|
-
* if (context) {
|
|
75
|
-
* console.log('Already have context:', context.orgId);
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
function getCurrentContext() {
|
|
80
|
-
return currentContext;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Navigate the ManageSpace host application to a specific path.
|
|
84
|
-
*
|
|
85
|
-
* Use this to navigate users to pages within ManageSpace, such as
|
|
86
|
-
* customer profiles, asset details, or other views.
|
|
87
|
-
*
|
|
88
|
-
* @param path - The path to navigate to (e.g., "/customer/123")
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```typescript
|
|
92
|
-
* import { navigate } from '@managespace/sdk/extensions';
|
|
93
|
-
*
|
|
94
|
-
* // Navigate to a customer profile
|
|
95
|
-
* navigate('/customer/abc-123');
|
|
96
|
-
*
|
|
97
|
-
* // Navigate to the assets page
|
|
98
|
-
* navigate('/assets');
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
function navigate(path) {
|
|
102
|
-
const message = {
|
|
103
|
-
type: 'NAVIGATE',
|
|
104
|
-
payload: { path },
|
|
105
|
-
};
|
|
106
|
-
window.parent.postMessage(message, '*');
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Show a toast notification in the ManageSpace host application.
|
|
110
|
-
*
|
|
111
|
-
* Use this for user feedback after actions complete.
|
|
112
|
-
*
|
|
113
|
-
* @param message - The message to display
|
|
114
|
-
* @param variant - The toast type: 'success' or 'error' (default: 'success')
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```typescript
|
|
118
|
-
* import { showToast } from '@managespace/sdk/extensions';
|
|
119
|
-
*
|
|
120
|
-
* // Success notification
|
|
121
|
-
* showToast('Customer updated successfully');
|
|
122
|
-
*
|
|
123
|
-
* // Error notification
|
|
124
|
-
* showToast('Failed to save changes', 'error');
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
function showToast(message, variant = 'success') {
|
|
128
|
-
const msg = {
|
|
129
|
-
type: 'SHOW_TOAST',
|
|
130
|
-
payload: { message, variant },
|
|
131
|
-
};
|
|
132
|
-
window.parent.postMessage(msg, '*');
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Signal to the ManageSpace host that the extension is ready to receive context.
|
|
136
|
-
*
|
|
137
|
-
* Call this after your extension has loaded and set up its message listeners.
|
|
138
|
-
* The host will respond with a CONTEXT_INIT message containing the ExtensionContext.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* import { signalReady, getContext } from '@managespace/sdk/extensions';
|
|
143
|
-
*
|
|
144
|
-
* // Signal ready and wait for context
|
|
145
|
-
* signalReady();
|
|
146
|
-
* const context = await getContext();
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
function signalReady() {
|
|
150
|
-
const message = { type: 'READY' };
|
|
151
|
-
window.parent.postMessage(message, '*');
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Subscribe to entity events from the ManageSpace host.
|
|
155
|
-
*
|
|
156
|
-
* The host sends events when entities (customers, assets, etc.) are
|
|
157
|
-
* created, updated, or deleted. Use this to keep your extension in sync.
|
|
158
|
-
*
|
|
159
|
-
* @param handler - Callback function to handle entity events
|
|
160
|
-
* @returns Unsubscribe function to remove the handler
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* import { onEntityEvent } from '@managespace/sdk/extensions';
|
|
165
|
-
*
|
|
166
|
-
* const unsubscribe = onEntityEvent((event) => {
|
|
167
|
-
* if (event.entityType === 'customer' && event.action === 'updated') {
|
|
168
|
-
* console.log('Customer updated:', event.entityId);
|
|
169
|
-
* refreshCustomerData();
|
|
170
|
-
* }
|
|
171
|
-
* });
|
|
172
|
-
*
|
|
173
|
-
* // Later, to stop listening:
|
|
174
|
-
* unsubscribe();
|
|
175
|
-
* ```
|
|
176
|
-
*/
|
|
177
|
-
function onEntityEvent(handler) {
|
|
178
|
-
entityEventHandlers.add(handler);
|
|
179
|
-
return () => {
|
|
180
|
-
entityEventHandlers.delete(handler);
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Create a configured fetch function for calling the ManageSpace API.
|
|
185
|
-
*
|
|
186
|
-
* This returns a fetch wrapper that automatically includes credentials
|
|
187
|
-
* and sets the correct headers for API calls.
|
|
188
|
-
*
|
|
189
|
-
* @param context - The extension context from getContext()
|
|
190
|
-
* @returns A fetch function configured for ManageSpace API calls
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```typescript
|
|
194
|
-
* import { getContext, createApiFetch } from '@managespace/sdk/extensions';
|
|
195
|
-
*
|
|
196
|
-
* const context = await getContext();
|
|
197
|
-
* const apiFetch = createApiFetch(context);
|
|
198
|
-
*
|
|
199
|
-
* // Fetch customers
|
|
200
|
-
* const response = await apiFetch('/api/crm/customers/queries', {
|
|
201
|
-
* method: 'POST',
|
|
202
|
-
* body: JSON.stringify({
|
|
203
|
-
* pageOptions: { offset: 0, limit: 20 }
|
|
204
|
-
* })
|
|
205
|
-
* });
|
|
206
|
-
* const data = await response.json();
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
function createApiFetch(context) {
|
|
210
|
-
return (path, options = {}) => {
|
|
211
|
-
const url = `${context.apiBaseUrl}${path}`;
|
|
212
|
-
return fetch(url, {
|
|
213
|
-
...options,
|
|
214
|
-
credentials: 'include',
|
|
215
|
-
headers: {
|
|
216
|
-
'Content-Type': 'application/json',
|
|
217
|
-
...options.headers,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Create a configured fetch function for calling your extension's BFF.
|
|
224
|
-
*
|
|
225
|
-
* This returns a fetch wrapper that forwards credentials to your BFF,
|
|
226
|
-
* allowing it to make authenticated calls to the ManageSpace API.
|
|
227
|
-
*
|
|
228
|
-
* @param context - The extension context from getContext()
|
|
229
|
-
* @returns A fetch function configured for BFF calls, or null if no BFF is configured
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* import { getContext, createBffFetch } from '@managespace/sdk/extensions';
|
|
234
|
-
*
|
|
235
|
-
* const context = await getContext();
|
|
236
|
-
* const bffFetch = createBffFetch(context);
|
|
237
|
-
*
|
|
238
|
-
* if (bffFetch) {
|
|
239
|
-
* const response = await bffFetch('/api/enriched-customers');
|
|
240
|
-
* const data = await response.json();
|
|
241
|
-
* }
|
|
242
|
-
* ```
|
|
243
|
-
*/
|
|
244
|
-
function createBffFetch(context) {
|
|
245
|
-
if (!context.bffUrl) {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
return (path, options = {}) => {
|
|
249
|
-
const url = `${context.bffUrl}${path}`;
|
|
250
|
-
return fetch(url, {
|
|
251
|
-
...options,
|
|
252
|
-
credentials: 'include',
|
|
253
|
-
headers: {
|
|
254
|
-
'Content-Type': 'application/json',
|
|
255
|
-
...options.headers,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
};
|
|
259
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ManageSpace Extension SDK
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for building extensions that run within
|
|
5
|
-
* the ManageSpace platform. Extensions are loaded in iframes and communicate
|
|
6
|
-
* with the host application via postMessage.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import {
|
|
11
|
-
* getContext,
|
|
12
|
-
* signalReady,
|
|
13
|
-
* navigate,
|
|
14
|
-
* showToast,
|
|
15
|
-
* createApiFetch,
|
|
16
|
-
* } from '@managespace/sdk/extensions';
|
|
17
|
-
*
|
|
18
|
-
* // Signal ready and get context
|
|
19
|
-
* signalReady();
|
|
20
|
-
* const context = await getContext();
|
|
21
|
-
*
|
|
22
|
-
* // Create API client
|
|
23
|
-
* const apiFetch = createApiFetch(context);
|
|
24
|
-
*
|
|
25
|
-
* // Fetch data
|
|
26
|
-
* const response = await apiFetch('/api/crm/customers/queries', {
|
|
27
|
-
* method: 'POST',
|
|
28
|
-
* body: JSON.stringify({ pageOptions: { offset: 0, limit: 20 } })
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* // Navigate and show feedback
|
|
32
|
-
* navigate('/customer/123');
|
|
33
|
-
* showToast('Customer loaded');
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @module extensions
|
|
37
|
-
*/
|
|
38
|
-
export * from './types';
|
|
39
|
-
export * from './host-bridge';
|
|
40
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
package/dist/extensions/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ManageSpace Extension SDK
|
|
4
|
-
*
|
|
5
|
-
* This module provides utilities for building extensions that run within
|
|
6
|
-
* the ManageSpace platform. Extensions are loaded in iframes and communicate
|
|
7
|
-
* with the host application via postMessage.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* import {
|
|
12
|
-
* getContext,
|
|
13
|
-
* signalReady,
|
|
14
|
-
* navigate,
|
|
15
|
-
* showToast,
|
|
16
|
-
* createApiFetch,
|
|
17
|
-
* } from '@managespace/sdk/extensions';
|
|
18
|
-
*
|
|
19
|
-
* // Signal ready and get context
|
|
20
|
-
* signalReady();
|
|
21
|
-
* const context = await getContext();
|
|
22
|
-
*
|
|
23
|
-
* // Create API client
|
|
24
|
-
* const apiFetch = createApiFetch(context);
|
|
25
|
-
*
|
|
26
|
-
* // Fetch data
|
|
27
|
-
* const response = await apiFetch('/api/crm/customers/queries', {
|
|
28
|
-
* method: 'POST',
|
|
29
|
-
* body: JSON.stringify({ pageOptions: { offset: 0, limit: 20 } })
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
* // Navigate and show feedback
|
|
33
|
-
* navigate('/customer/123');
|
|
34
|
-
* showToast('Customer loaded');
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @module extensions
|
|
38
|
-
*/
|
|
39
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
40
|
-
if (k2 === undefined) k2 = k;
|
|
41
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
42
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
43
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(o, k2, desc);
|
|
46
|
-
}) : (function(o, m, k, k2) {
|
|
47
|
-
if (k2 === undefined) k2 = k;
|
|
48
|
-
o[k2] = m[k];
|
|
49
|
-
}));
|
|
50
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
51
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
__exportStar(require("./types"), exports);
|
|
55
|
-
__exportStar(require("./host-bridge"), exports);
|