@halix/action-sdk 1.0.19 → 1.0.21
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/lib/cjs/content.js +257 -0
- package/lib/cjs/data-crud.js +297 -0
- package/lib/cjs/index.js +53 -678
- package/lib/cjs/lists.js +175 -0
- package/lib/cjs/sdk-general.js +92 -0
- package/lib/cjs/types/content.d.ts +119 -0
- package/lib/cjs/types/content.d.ts.map +1 -0
- package/lib/cjs/types/data-crud.d.ts +156 -0
- package/lib/cjs/types/data-crud.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts +8 -578
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/lists.d.ts +212 -0
- package/lib/cjs/types/lists.d.ts.map +1 -0
- package/lib/cjs/types/sdk-general.d.ts +263 -0
- package/lib/cjs/types/sdk-general.d.ts.map +1 -0
- package/lib/cjs/types/utilities.d.ts +73 -0
- package/lib/cjs/types/utilities.d.ts.map +1 -0
- package/lib/cjs/utilities.js +131 -0
- package/lib/esm/content.js +228 -0
- package/lib/esm/content.js.map +1 -0
- package/lib/esm/data-crud.js +264 -0
- package/lib/esm/data-crud.js.map +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/index.mjs +26 -673
- package/lib/esm/lists.js +157 -0
- package/lib/esm/lists.js.map +1 -0
- package/lib/esm/sdk-general.js +138 -0
- package/lib/esm/sdk-general.js.map +1 -0
- package/lib/esm/types/content.d.ts +118 -0
- package/lib/esm/types/data-crud.d.ts +155 -0
- package/lib/esm/types/index.d.ts +8 -578
- package/lib/esm/types/lists.d.ts +211 -0
- package/lib/esm/types/sdk-general.d.ts +262 -0
- package/lib/esm/types/utilities.d.ts +72 -0
- package/lib/esm/utilities.js +126 -0
- package/lib/esm/utilities.js.map +1 -0
- package/package.json +12 -1
package/lib/esm/lists.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Halix SDK License v1.0
|
|
2
|
+
// Copyright (c) 2025 halix.io LLC.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed for use **only** within applications
|
|
5
|
+
// running on the Halix platform, in accordance with Halix SDK guidelines.
|
|
6
|
+
//
|
|
7
|
+
// Unauthorized use outside the Halix platform is prohibited.
|
|
8
|
+
// Full license terms available in the LICENSE file.
|
|
9
|
+
/**
|
|
10
|
+
* @module @halix/action-sdk/lists
|
|
11
|
+
* @description List data retrieval functions. Use this to efficiently retrieve objects
|
|
12
|
+
* from the database for display in list-like user interfaces. This is preferred over
|
|
13
|
+
* the `data-crud` module when showing one page of data at a time.
|
|
14
|
+
*
|
|
15
|
+
* Key features:
|
|
16
|
+
* - Efficient retrieval of one page of data at a time
|
|
17
|
+
* - Pagination
|
|
18
|
+
* - Sorting
|
|
19
|
+
* - Filtering
|
|
20
|
+
* - Search
|
|
21
|
+
*/
|
|
22
|
+
import axios from 'axios';
|
|
23
|
+
import { from, lastValueFrom } from 'rxjs';
|
|
24
|
+
import { sandboxKey, serviceAddress, getAuthToken } from './sdk-general';
|
|
25
|
+
// ================================================================================
|
|
26
|
+
// LIST DATA RETRIEVAL FUNCTIONS
|
|
27
|
+
// ================================================================================
|
|
28
|
+
/**
|
|
29
|
+
* getListData retrieves list data from the Halix platform. This function can operate in four
|
|
30
|
+
* different modes based on the provided options:
|
|
31
|
+
*
|
|
32
|
+
* 1. Authenticated list data retrieval (default)
|
|
33
|
+
* 2. Public list data retrieval (when isPublic is true)
|
|
34
|
+
* 3. Authenticated list data with search (when search options are provided)
|
|
35
|
+
* 4. Public list data with search (when both isPublic and search options are provided)
|
|
36
|
+
*
|
|
37
|
+
* The search functionality uses binary search to efficiently locate items in a sorted list by
|
|
38
|
+
* a specific attribute value.
|
|
39
|
+
*
|
|
40
|
+
* @param request - The list data request containing list configuration and parameters
|
|
41
|
+
* @param options - Optional configuration for the request
|
|
42
|
+
*
|
|
43
|
+
* @returns Promise resolving to the list data response
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Basic authenticated list data retrieval
|
|
47
|
+
* const listData = await getListData({
|
|
48
|
+
* dataElementId: 'customer',
|
|
49
|
+
* parentDataElementId: 'company',
|
|
50
|
+
* parentKey: orgProxyKey,
|
|
51
|
+
* pageNumber: 1,
|
|
52
|
+
* pageSize: 50,
|
|
53
|
+
* displayFields: ['firstName', 'lastName', 'email']
|
|
54
|
+
* });
|
|
55
|
+
* console.log('Total customers:', listData.total);
|
|
56
|
+
* console.log('Page:', listData.pageNumber);
|
|
57
|
+
* console.log('Data:', listData.data);
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Public list data retrieval without authentication
|
|
61
|
+
* const publicData = await getListData({
|
|
62
|
+
* dataElementId: 'product',
|
|
63
|
+
* parentDataElementId: 'catalog',
|
|
64
|
+
* parentKey: orgProxyKey,
|
|
65
|
+
* pageNumber: 1,
|
|
66
|
+
* pageSize: 20
|
|
67
|
+
* }, { isPublic: true });
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // List data retrieval with binary search
|
|
71
|
+
* const searchData = await getListData({
|
|
72
|
+
* dataElementId: 'purchases',
|
|
73
|
+
* parentDataElementId: 'customer',
|
|
74
|
+
* parentKey: userProxyKey,
|
|
75
|
+
* sort: [{ attributeId: 'invoiceNumber', descending: false }]
|
|
76
|
+
* }, {
|
|
77
|
+
* search: {
|
|
78
|
+
* attributeId: 'invoiceNumber',
|
|
79
|
+
* value: 'INV-123456',
|
|
80
|
+
* total: 1000
|
|
81
|
+
* }
|
|
82
|
+
* });
|
|
83
|
+
* console.log('Selected row index:', searchData.selectedRow);
|
|
84
|
+
*/
|
|
85
|
+
export async function getListData(request, options) {
|
|
86
|
+
const isPublic = options?.isPublic ?? false;
|
|
87
|
+
const hasSearch = !!options?.search;
|
|
88
|
+
// Determine which endpoint to use based on public access and search requirements
|
|
89
|
+
let url;
|
|
90
|
+
if (hasSearch && isPublic) {
|
|
91
|
+
url = `${serviceAddress}/list/sandboxes/${sandboxKey}/public/listdataSearch`;
|
|
92
|
+
}
|
|
93
|
+
else if (hasSearch && !isPublic) {
|
|
94
|
+
url = `${serviceAddress}/list/sandboxes/${sandboxKey}/listdataSearch`;
|
|
95
|
+
}
|
|
96
|
+
else if (!hasSearch && isPublic) {
|
|
97
|
+
url = `${serviceAddress}/list/sandboxes/${sandboxKey}/public/listdata`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
url = `${serviceAddress}/list/sandboxes/${sandboxKey}/listdata`;
|
|
101
|
+
}
|
|
102
|
+
// Build query parameters
|
|
103
|
+
let params = {};
|
|
104
|
+
// Add bypassTotal parameter if specified
|
|
105
|
+
if (options?.bypassTotal !== undefined) {
|
|
106
|
+
params.bypassTotal = options.bypassTotal;
|
|
107
|
+
}
|
|
108
|
+
// Add search parameters if search is enabled
|
|
109
|
+
if (hasSearch && options?.search) {
|
|
110
|
+
params.attributeId = options.search.attributeId;
|
|
111
|
+
params.value = options.search.value;
|
|
112
|
+
params.total = options.search.total.toString();
|
|
113
|
+
}
|
|
114
|
+
// Build headers with authentication token for non-public endpoints
|
|
115
|
+
let headers = {};
|
|
116
|
+
if (!isPublic) {
|
|
117
|
+
let authToken = await lastValueFrom(getAuthToken());
|
|
118
|
+
headers.Authorization = `Bearer ${authToken}`;
|
|
119
|
+
console.log("Sending POST request to " + url + " with token " + authToken);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log("Sending POST request to " + url + " (public endpoint)");
|
|
123
|
+
}
|
|
124
|
+
// Make the API request
|
|
125
|
+
let response = await axios.post(url, request, {
|
|
126
|
+
headers,
|
|
127
|
+
params: Object.keys(params).length > 0 ? params : undefined,
|
|
128
|
+
});
|
|
129
|
+
return response.data;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* getListDataAsObservable retrieves list data from the Halix platform as an Observable. This
|
|
133
|
+
* function operates in the same four modes as getListData.
|
|
134
|
+
*
|
|
135
|
+
* @param request - The list data request containing list configuration and parameters
|
|
136
|
+
* @param options - Optional configuration for the request
|
|
137
|
+
*
|
|
138
|
+
* @returns Observable resolving to the list data response
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // Basic authenticated list data retrieval as Observable
|
|
142
|
+
* getListDataAsObservable({
|
|
143
|
+
* dataElementId: 'customer',
|
|
144
|
+
* parentDataElementId: 'company',
|
|
145
|
+
* parentKey: userContext.orgProxyKey,
|
|
146
|
+
* pageNumber: 1,
|
|
147
|
+
* pageSize: 50
|
|
148
|
+
* }).subscribe(response => {
|
|
149
|
+
* console.log('Total customers:', response.total);
|
|
150
|
+
* console.log('Page:', response.pageNumber);
|
|
151
|
+
* console.log('Data:', response.data);
|
|
152
|
+
* });
|
|
153
|
+
*/
|
|
154
|
+
export function getListDataAsObservable(request, options) {
|
|
155
|
+
return from(getListData(request, options));
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.js","sourceRoot":"","sources":["../../src/lists.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAc,aAAa,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAyJzE,mFAAmF;AACnF,gCAAgC;AAChC,mFAAmF;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAwB,EAAE,OAAyB;IAEjF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,KAAK,CAAC;IAC5C,MAAM,SAAS,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,GAAG,CAAC,0BAA0B,GAAG,GAAG,GAAG,cAAc,GAAG,SAAS,CAAC,CAAC;IAC/E,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,GAAG,GAAG,oBAAoB,CAAC,CAAC;IACzE,CAAC;IAED,uBAAuB;IACvB,IAAI,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE;QAC1C,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KAC9D,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAwB,EAAE,OAAyB;IACvF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Halix SDK License v1.0
|
|
2
|
+
// Copyright (c) 2025 halix.io LLC.
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed for use **only** within applications
|
|
5
|
+
// running on the Halix platform, in accordance with Halix SDK guidelines.
|
|
6
|
+
//
|
|
7
|
+
// Unauthorized use outside the Halix platform is prohibited.
|
|
8
|
+
// Full license terms available in the LICENSE file.
|
|
9
|
+
/**
|
|
10
|
+
* @module @halix/action-sdk/sdk-general
|
|
11
|
+
* @description Core SDK module providing global variables, initialization, and common types used
|
|
12
|
+
* across the entire SDK. This module includes:
|
|
13
|
+
* - Global variables for authentication, service configuration, and user context
|
|
14
|
+
* - initialize() function for setting up the SDK with incoming event data
|
|
15
|
+
* - Action response type definitions (ListActionResponse, FormTemplateActionResponse, etc.)
|
|
16
|
+
* - Response formatting helpers (prepareSuccessResponse, prepareErrorResponse)
|
|
17
|
+
* - Common interfaces (UserContext, IncomingEventBody, NotificationConfig)
|
|
18
|
+
*
|
|
19
|
+
* This module should be initialized by calling initialize() before using any other SDK functions.
|
|
20
|
+
* The global variables are then available for use and are automatically used by other SDK functions.
|
|
21
|
+
*/
|
|
22
|
+
import { of } from 'rxjs';
|
|
23
|
+
// ================================================================================
|
|
24
|
+
// GLOBAL VARIABLES AND INITIALIZATION
|
|
25
|
+
// ================================================================================
|
|
26
|
+
/**
|
|
27
|
+
* authToken contains the authentication token that the action handler can use to make API requests
|
|
28
|
+
* to Halix web services. This value is set upon calling the initialize function with incoming event
|
|
29
|
+
* data.
|
|
30
|
+
*/
|
|
31
|
+
export let getAuthToken;
|
|
32
|
+
/**
|
|
33
|
+
* sandboxKey contains the sandbox key identifier; identifies the sandbox that the action handler is
|
|
34
|
+
* running in. The sandbox identifies the current solution. This value is set upon calling the
|
|
35
|
+
* initialize function with incoming event data.
|
|
36
|
+
*/
|
|
37
|
+
export let sandboxKey;
|
|
38
|
+
/**
|
|
39
|
+
* serviceAddress contains the URL of the Halix service that the action handler can use to make API
|
|
40
|
+
* requests to. This value is set upon calling the initialize function with incoming event data.
|
|
41
|
+
*/
|
|
42
|
+
export let serviceAddress;
|
|
43
|
+
/**
|
|
44
|
+
* actionSubject contains the identifier of the subject of the action. The subject is the object
|
|
45
|
+
* that the action is being performed on. The action subject's contents will differ depending on the
|
|
46
|
+
* context in which the action is being executed. This value is set upon calling the initialize
|
|
47
|
+
* function with incoming event data.
|
|
48
|
+
* - for formTemplateActions, the action subject is the data being edited on the form
|
|
49
|
+
* - for pageTemplateActions, the action subject is record containing the context variables and
|
|
50
|
+
* their corresponding values on the page
|
|
51
|
+
* - for objectSaveActions, the action subject is the object being saved
|
|
52
|
+
* - for calculatedFieldActions, the action subject is the object containing the calculated field
|
|
53
|
+
* - for singleValueActions, the action subject may differ depending on the caller
|
|
54
|
+
*/
|
|
55
|
+
export let actionSubject;
|
|
56
|
+
/**
|
|
57
|
+
* userContext contains the user context information for the user that is executing the action.
|
|
58
|
+
* This value is set upon calling the initialize function with incoming event data.
|
|
59
|
+
*/
|
|
60
|
+
export let userContext;
|
|
61
|
+
/**
|
|
62
|
+
* params contains the parameters passed to the action. If an input dialog is used, params will
|
|
63
|
+
* contain the values entered in the dialog. This value is set upon calling the initialize
|
|
64
|
+
* function with incoming event data.
|
|
65
|
+
*/
|
|
66
|
+
export let params;
|
|
67
|
+
/**
|
|
68
|
+
* useBody is a flag indicating how responses should be formatted. If true, the response will be
|
|
69
|
+
* returned as an object with the HTTP response code and ActionResponse in the body field. If false,
|
|
70
|
+
* the ActionResponse will be returned directly. Typically, this does not need to be set by the
|
|
71
|
+
* action handler and should remain false.
|
|
72
|
+
*/
|
|
73
|
+
export let useBody;
|
|
74
|
+
/**
|
|
75
|
+
* initialize initializes the SDK with event data. This should be called at the beginning of the
|
|
76
|
+
* action handler to set up the SDK with incoming information, including context information, input
|
|
77
|
+
* parameters, and authentication information needed to make API requests to the Halix service.
|
|
78
|
+
*
|
|
79
|
+
* @param event - The event object containing authentication and context information
|
|
80
|
+
*/
|
|
81
|
+
export function initialize(event) {
|
|
82
|
+
let body = event;
|
|
83
|
+
if (event.body) {
|
|
84
|
+
body = event.body;
|
|
85
|
+
useBody = true;
|
|
86
|
+
}
|
|
87
|
+
if (body) {
|
|
88
|
+
({ sandboxKey, serviceAddress, actionSubject, userContext, params } = body);
|
|
89
|
+
if (body.authToken) {
|
|
90
|
+
getAuthToken = () => of(body.authToken);
|
|
91
|
+
}
|
|
92
|
+
else if (body.authTokenRetriever) {
|
|
93
|
+
getAuthToken = body.authTokenRetriever;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// ================================================================================
|
|
98
|
+
// RESPONSE HELPER FUNCTIONS
|
|
99
|
+
// ================================================================================
|
|
100
|
+
/**
|
|
101
|
+
* prepareSuccessResponse prepares a success response in the appropriate format. The action handler
|
|
102
|
+
* should return an ActionResponse response when the action is successful. If useBody is true, the
|
|
103
|
+
* response will be returned as an object with the HTTP response code and the ActionResponse in the
|
|
104
|
+
* body field. If useBody is false, the ActionResponse will be returned directly.
|
|
105
|
+
*
|
|
106
|
+
* @param successResponse - The value to return
|
|
107
|
+
*
|
|
108
|
+
* @returns Formatted success response; an ActionResponse unless useBody is true
|
|
109
|
+
*/
|
|
110
|
+
export function prepareSuccessResponse(successResponse) {
|
|
111
|
+
if (useBody) {
|
|
112
|
+
return {
|
|
113
|
+
statusCode: 200,
|
|
114
|
+
body: JSON.stringify(successResponse)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return successResponse;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* prepareErrorResponse prepares an error response in the appropriate format. The action handler
|
|
121
|
+
* should return an ErrorResponse response when the action is not successful. If useBody is true,
|
|
122
|
+
* the response will be returned as an object with the HTTP response code and the ErrorResponse in
|
|
123
|
+
* the body field. If useBody is false, the ErrorResponse will be returned directly.
|
|
124
|
+
*
|
|
125
|
+
* @param errorMessage - The error message
|
|
126
|
+
*
|
|
127
|
+
* @returns Formatted error response; an ErrorResponse unless useBody is true
|
|
128
|
+
*/
|
|
129
|
+
export function prepareErrorResponse(errorMessage) {
|
|
130
|
+
if (useBody) {
|
|
131
|
+
return {
|
|
132
|
+
statusCode: 400,
|
|
133
|
+
body: JSON.stringify({ errorMessage })
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return { errorMessage, responseType: "error" };
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=sdk-general.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-general.js","sourceRoot":"","sources":["../../src/sdk-general.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,mCAAmC;AACnC,EAAE;AACF,oEAAoE;AACpE,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,oDAAoD;AAEpD;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAc,EAAE,EA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E,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC;SACxC,CAAC;IACN,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACrD,IAAI,OAAO,EAAE,CAAC;QACV,OAAO;YACH,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;SACzC,CAAC;IACN,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* ContentResource is an interface defining the properties of a content resource.
|
|
4
|
+
*/
|
|
5
|
+
export interface ContentResource {
|
|
6
|
+
objKey?: string;
|
|
7
|
+
isPublic: boolean;
|
|
8
|
+
resourceType: string;
|
|
9
|
+
tags: string[];
|
|
10
|
+
organizationKey: string;
|
|
11
|
+
sandboxKey: string;
|
|
12
|
+
userKey: string;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
fileSize?: number;
|
|
15
|
+
mimeType?: string;
|
|
16
|
+
contentType?: string;
|
|
17
|
+
name?: string | null;
|
|
18
|
+
extension?: string | null;
|
|
19
|
+
deserialize?: (data: any) => ContentResource;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* getOrCreateResource retrieves an existing content resource by its key, or creates a new one
|
|
23
|
+
* if the key is not provided. If a resource key is provided, it attempts to fetch the existing
|
|
24
|
+
* resource from the server. If no key is provided, it creates a new resource with the specified
|
|
25
|
+
* properties.
|
|
26
|
+
*
|
|
27
|
+
* @param resourceKey - Optional key of the existing resource to retrieve
|
|
28
|
+
* @param fileToUpload - Optional file or blob to upload
|
|
29
|
+
* @param publicFlag - Whether the resource should be public
|
|
30
|
+
* @param resourceType - The type of resource
|
|
31
|
+
* @param tags - Array of tags for the resource
|
|
32
|
+
*
|
|
33
|
+
* @returns Promise resolving to a ContentResource
|
|
34
|
+
*/
|
|
35
|
+
export declare function getOrCreateResource(resourceKey: string | null, fileToUpload: File | Blob | null, publicFlag: boolean, resourceType: string, tags: string[]): Promise<ContentResource>;
|
|
36
|
+
/**
|
|
37
|
+
* getOrCreateResourceAsObservable retrieves an existing content resource by its key, or creates a new one
|
|
38
|
+
* if the key is not provided. If a resource key is provided, it attempts to fetch the existing
|
|
39
|
+
* resource from the server. If no key is provided, it creates a new resource with the specified
|
|
40
|
+
* properties.
|
|
41
|
+
*
|
|
42
|
+
* @param resourceKey - Optional key of the existing resource to retrieve
|
|
43
|
+
* @param fileToUpload - Optional file or blob to upload
|
|
44
|
+
* @param publicFlag - Whether the resource should be public
|
|
45
|
+
* @param resourceType - The type of resource
|
|
46
|
+
* @param tags - Array of tags for the resource
|
|
47
|
+
*
|
|
48
|
+
* @returns Observable resolving to a ContentResource
|
|
49
|
+
*/
|
|
50
|
+
export declare function getOrCreateResourceAsObservable(resourceKey: string | null, fileToUpload: File | Blob | null, publicFlag: boolean, resourceType: string, tags: string[]): Observable<ContentResource>;
|
|
51
|
+
/**
|
|
52
|
+
* saveResource saves a content resource to the server. The resource is saved with appropriate
|
|
53
|
+
* ownership parameters based on the current context (solution builder vs regular organization view).
|
|
54
|
+
*
|
|
55
|
+
* @param resource - The ContentResource to save
|
|
56
|
+
*
|
|
57
|
+
* @returns Promise resolving to the saved ContentResource
|
|
58
|
+
*/
|
|
59
|
+
export declare function saveResource(resource: ContentResource): Promise<ContentResource>;
|
|
60
|
+
/**
|
|
61
|
+
* saveResourceAsObservable saves a content resource to the server. The resource is saved with appropriate
|
|
62
|
+
* ownership parameters based on the current context (solution builder vs regular organization view).
|
|
63
|
+
*
|
|
64
|
+
* @param resource - The ContentResource to save
|
|
65
|
+
*
|
|
66
|
+
* @returns Observable resolving to the saved ContentResource
|
|
67
|
+
*/
|
|
68
|
+
export declare function saveResourceAsObservable(resource: ContentResource): Observable<ContentResource>;
|
|
69
|
+
/**
|
|
70
|
+
* sendFileContents uploads file contents to the server for a specific resource. The file is uploaded
|
|
71
|
+
* via FormData with the appropriate scope and public flag settings.
|
|
72
|
+
*
|
|
73
|
+
* @param resourceKey - The key of the resource to upload file contents for
|
|
74
|
+
* @param fileToUpload - The file or blob to upload
|
|
75
|
+
* @param publicFlag - Whether the file should be public
|
|
76
|
+
*
|
|
77
|
+
* @returns Promise resolving to true if upload was successful
|
|
78
|
+
*/
|
|
79
|
+
export declare function sendFileContents(resourceKey: string, fileToUpload: File | Blob, publicFlag: boolean): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* sendFileContentsAsObservable uploads file contents to the server for a specific resource. The file is uploaded
|
|
82
|
+
* via FormData with the appropriate scope and public flag settings.
|
|
83
|
+
*
|
|
84
|
+
* @param resourceKey - The key of the resource to upload file contents for
|
|
85
|
+
* @param fileToUpload - The file or blob to upload
|
|
86
|
+
* @param publicFlag - Whether the file should be public
|
|
87
|
+
*
|
|
88
|
+
* @returns Observable resolving to true if upload was successful
|
|
89
|
+
*/
|
|
90
|
+
export declare function sendFileContentsAsObservable(resourceKey: string, fileToUpload: File | Blob, publicFlag: boolean): Observable<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* createOrUpdateResource creates a new content resource or updates an existing one, then uploads
|
|
93
|
+
* the file contents to that resource. If a resourceKey is provided, it updates the existing resource;
|
|
94
|
+
* otherwise, it creates a new resource and uploads the file to the newly created resource.
|
|
95
|
+
*
|
|
96
|
+
* @param resourceKey - Optional key of the existing resource to update; if not provided, a new resource is created
|
|
97
|
+
* @param fileToUpload - The file or blob to upload
|
|
98
|
+
* @param publicFlag - Whether the resource should be public
|
|
99
|
+
* @param resourceType - The type of resource
|
|
100
|
+
* @param tags - Array of tags for the resource
|
|
101
|
+
*
|
|
102
|
+
* @returns Promise resolving to the ContentResource with uploaded file
|
|
103
|
+
*/
|
|
104
|
+
export declare function createOrUpdateResource(resourceKey: string | null, fileToUpload: File | Blob, publicFlag: boolean, resourceType: string, tags: string[]): Promise<ContentResource>;
|
|
105
|
+
/**
|
|
106
|
+
* createOrUpdateResourceAsObservable creates a new content resource or updates an existing one, then uploads
|
|
107
|
+
* the file contents to that resource. If a resourceKey is provided, it updates the existing resource;
|
|
108
|
+
* otherwise, it creates a new resource and uploads the file to the newly created resource.
|
|
109
|
+
*
|
|
110
|
+
* @param resourceKey - Optional key of the existing resource to update; if not provided, a new resource is created
|
|
111
|
+
* @param fileToUpload - The file or blob to upload
|
|
112
|
+
* @param publicFlag - Whether the resource should be public
|
|
113
|
+
* @param resourceType - The type of resource
|
|
114
|
+
* @param tags - Array of tags for the resource
|
|
115
|
+
*
|
|
116
|
+
* @returns Observable resolving to the ContentResource with uploaded file
|
|
117
|
+
*/
|
|
118
|
+
export declare function createOrUpdateResourceAsObservable(resourceKey: string | null, fileToUpload: File | Blob, publicFlag: boolean, resourceType: string, tags: string[]): Observable<ContentResource>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* SaveOptions is an interface for specifying save operation options.
|
|
4
|
+
*/
|
|
5
|
+
export interface SaveOptions {
|
|
6
|
+
/** Whether to bypass validation */
|
|
7
|
+
bypassValidation?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* getObject retrieves a single object from the database by its data element ID and key.
|
|
11
|
+
*
|
|
12
|
+
* @param dataElementId - The ID of the data element
|
|
13
|
+
* @param key - The key of the object
|
|
14
|
+
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
15
|
+
* object will include the specified related objects as nested objects
|
|
16
|
+
* @returns Promise resolving to the object data
|
|
17
|
+
*/
|
|
18
|
+
export declare function getObject(dataElementId: string, key: string, fetchedRelationships?: string[]): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* getObjectAsObservable retrieves a single object from the database by its data element ID and key.
|
|
21
|
+
*
|
|
22
|
+
* @param dataElementId - The ID of the data element
|
|
23
|
+
* @param key - The key of the object
|
|
24
|
+
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
25
|
+
* object will include the specified related objects as nested objects
|
|
26
|
+
*
|
|
27
|
+
* @returns Observable resolving to the object data
|
|
28
|
+
*/
|
|
29
|
+
export declare function getObjectAsObservable(dataElementId: string, key: string, fetchedRelationships?: string[]): Observable<any>;
|
|
30
|
+
/**
|
|
31
|
+
* getRelatedObjects retrieves an array of objects from the the database. The objects returned are
|
|
32
|
+
* related to a parent through a defined relationship in the schema. In a typical setup, action's
|
|
33
|
+
* auth token must have scope access to the parent object in order to access all of its related
|
|
34
|
+
* objects.
|
|
35
|
+
*
|
|
36
|
+
* It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
|
|
37
|
+
* or organization proxy. For example, in a user context where the current user proxy element is
|
|
38
|
+
* "customer," an action might want to retrieve all "purchase" objects related to the current
|
|
39
|
+
* customer. Similarly, in an organization context where the current organization proxy is
|
|
40
|
+
* "business," an action might want to retrieve all "employee" objects related to the current
|
|
41
|
+
* business.
|
|
42
|
+
*
|
|
43
|
+
* @param parentElementId - The ID of the parent element
|
|
44
|
+
* @param parentKey - The key of the parent object
|
|
45
|
+
* @param elementId - The ID of the element
|
|
46
|
+
* @param filter - Optional filter criteria for the query; if not provided, all related objects will
|
|
47
|
+
* be returned
|
|
48
|
+
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
49
|
+
* objects will include the specified related objects as nested objects
|
|
50
|
+
*
|
|
51
|
+
* @returns Promise resolving to an array of objects
|
|
52
|
+
*/
|
|
53
|
+
export declare function getRelatedObjects(parentElementId: string, parentKey: string, elementId: string, filter?: string, fetchedRelationships?: string[]): Promise<any[]>;
|
|
54
|
+
/**
|
|
55
|
+
* getRelatedObjectsAsObservable retrieves an array of objects from the the database. The objects
|
|
56
|
+
* returned are related to a parent through a defined relationship in the schema. In a typical
|
|
57
|
+
* setup, action's auth token must have scope access to the parent object in order to access all of
|
|
58
|
+
* its related objects.
|
|
59
|
+
*
|
|
60
|
+
* It is common to use getRelatedObjects to retrieve all objects belonging to the current user proxy
|
|
61
|
+
* or organization proxy. For example, in a user context where the current user proxy element is
|
|
62
|
+
* "customer," an action might want to retrieve all "purchase" objects related to the current
|
|
63
|
+
* customer. Similarly, in an organization context where the current organization proxy is
|
|
64
|
+
* "business," an action might want to retrieve all "employee" objects related to the current
|
|
65
|
+
* business.
|
|
66
|
+
*
|
|
67
|
+
* @param parentElementId - The ID of the parent element
|
|
68
|
+
* @param parentKey - The key of the parent element
|
|
69
|
+
* @param elementId - The ID of the element
|
|
70
|
+
* @param filter - Optional filter criteria for the query; if not provided, all related objects will
|
|
71
|
+
* be returned
|
|
72
|
+
* @param fetchedRelationships - Optional array of relationships to fetch; if provided, the returned
|
|
73
|
+
* objects will include the specified related objects as nested objects
|
|
74
|
+
*
|
|
75
|
+
* @returns Observable resolving to an array of objects
|
|
76
|
+
*/
|
|
77
|
+
export declare function getRelatedObjectsAsObservable(parentElementId: string, parentKey: string, elementId: string, filter?: string, fetchedRelationships?: string[]): Observable<any[]>;
|
|
78
|
+
/**
|
|
79
|
+
* saveRelatedObject saves a related object to the database. The objectToSave is saved, and its
|
|
80
|
+
* relationship to the parent object is established based on the relationship specified in the
|
|
81
|
+
* schema. The objectToSave must have a relationship to the parent object and the user must have
|
|
82
|
+
* scope access to the parent object.
|
|
83
|
+
*
|
|
84
|
+
* @param parentElementId - The ID of the parent element
|
|
85
|
+
* @param parentKey - The key of the parent object
|
|
86
|
+
* @param elementId - The element ID of the object to save
|
|
87
|
+
* @param objectToSave - The object data to save (as a JSON string)
|
|
88
|
+
* @param opts - Optional save options
|
|
89
|
+
*
|
|
90
|
+
* @returns Promise resolving to saved object, including any updates made to the object during the
|
|
91
|
+
* save operation (such as assigning an objKey if the object is new), or the assignment of
|
|
92
|
+
* calculated values
|
|
93
|
+
*/
|
|
94
|
+
export declare function saveRelatedObject(parentElementId: string, parentKey: string, elementId: string, objectToSave: string, opts?: SaveOptions): Promise<any>;
|
|
95
|
+
/**
|
|
96
|
+
* saveRelatedObjectAsObservable saves a related object to the database. The objectToSave is saved,
|
|
97
|
+
* and its relationship to the parent object is established based on the relationship specified in
|
|
98
|
+
* the schema. The objectToSave must have a relationship to the parent object and the user must have
|
|
99
|
+
* scope access to the parent object.
|
|
100
|
+
*
|
|
101
|
+
* @param parentElementId - The ID of the parent element
|
|
102
|
+
* @param parentKey - The key of the parent object
|
|
103
|
+
* @param elementId - The element ID of the object to save
|
|
104
|
+
* @param objectToSave - The object data to save (as a JSON string)
|
|
105
|
+
* @param opts - Optional save options
|
|
106
|
+
*
|
|
107
|
+
* @returns Observable resolving to saved object, including any updates made to the object during
|
|
108
|
+
* the save operation (such as assigning an objKey if the object is new), or the assignment of
|
|
109
|
+
* calculated values
|
|
110
|
+
*/
|
|
111
|
+
export declare function saveRelatedObjectAsObservable(parentElementId: string, parentKey: string, elementId: string, objectToSave: string, opts?: SaveOptions): Observable<any>;
|
|
112
|
+
/**
|
|
113
|
+
* deleteRelatedObject deletes a single object related to a specific parent.
|
|
114
|
+
*
|
|
115
|
+
* @param parentElementId - The ID of the parent element
|
|
116
|
+
* @param parentKey - The key of the parent object
|
|
117
|
+
* @param childElementId - The ID of the child element to delete
|
|
118
|
+
* @param childKey - The key of the child object to delete
|
|
119
|
+
*
|
|
120
|
+
* @returns Promise resolving to true if deletion was successful
|
|
121
|
+
*/
|
|
122
|
+
export declare function deleteRelatedObject(parentElementId: string, parentKey: string, childElementId: string, childKey: string): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* deleteRelatedObjectAsObservable deletes a single object related to a specific parent.
|
|
125
|
+
*
|
|
126
|
+
* @param parentElementId - The ID of the parent element
|
|
127
|
+
* @param parentKey - The key of the parent object
|
|
128
|
+
* @param childElementId - The ID of the child element to delete
|
|
129
|
+
* @param childKey - The key of the child object to delete
|
|
130
|
+
*
|
|
131
|
+
* @returns Observable resolving to true if deletion was successful
|
|
132
|
+
*/
|
|
133
|
+
export declare function deleteRelatedObjectAsObservable(parentElementId: string, parentKey: string, childElementId: string, childKey: string): Observable<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* deleteRelatedObjects deletes multiple objects related to a specific parent.
|
|
136
|
+
*
|
|
137
|
+
* @param parentElementId - The ID of the parent element
|
|
138
|
+
* @param parentKey - The key of the parent object
|
|
139
|
+
* @param childElementId - The ID of the child element to delete
|
|
140
|
+
* @param childKeys - Array of keys of the child objects to delete
|
|
141
|
+
*
|
|
142
|
+
* @returns Promise resolving to true if deletion was successful
|
|
143
|
+
*/
|
|
144
|
+
export declare function deleteRelatedObjects(parentElementId: string, parentKey: string, childElementId: string, childKeys: string[]): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* deleteRelatedObjectsAsObservable deletes multiple objects related to a specific parent.
|
|
147
|
+
*
|
|
148
|
+
* @param parentElementId - The ID of the parent element
|
|
149
|
+
* @param parentKey - The key of the parent object
|
|
150
|
+
* @param childElementId - The ID of the child element to delete
|
|
151
|
+
* @param childKeys - Array of keys of the child objects to delete
|
|
152
|
+
*
|
|
153
|
+
* @returns Observable resolving to true if deletion was successful
|
|
154
|
+
*/
|
|
155
|
+
export declare function deleteRelatedObjectsAsObservable(parentElementId: string, parentKey: string, childElementId: string, childKeys: string[]): Observable<boolean>;
|