resora 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +26 -6
- package/dist/index.d.cts +16 -1
- package/dist/index.d.mts +16 -1
- package/dist/index.mjs +26 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -457,6 +457,17 @@ const isArkormLikeCollection = (value) => {
|
|
|
457
457
|
return typeof value.all === "function";
|
|
458
458
|
};
|
|
459
459
|
/**
|
|
460
|
+
* Type guard to check if a value is a Resora collection-like serializer.
|
|
461
|
+
*
|
|
462
|
+
* @param value
|
|
463
|
+
* @returns
|
|
464
|
+
*/
|
|
465
|
+
const isResoraCollectionLike = (value) => {
|
|
466
|
+
if (!value || typeof value !== "object") return false;
|
|
467
|
+
const candidate = value;
|
|
468
|
+
return typeof candidate.toObject === "function" && typeof candidate.getBody === "function" && typeof candidate.json === "function" && typeof candidate.setCollects === "function";
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
460
471
|
* Normalize a value for serialization by recursively converting Arkorm-like models and
|
|
461
472
|
* collections to plain objects, while preserving the structure of arrays and plain objects.
|
|
462
473
|
*
|
|
@@ -465,6 +476,7 @@ const isArkormLikeCollection = (value) => {
|
|
|
465
476
|
*/
|
|
466
477
|
const normalizeSerializableData = (value) => {
|
|
467
478
|
if (Array.isArray(value)) return value.map((item) => normalizeSerializableData(item));
|
|
479
|
+
if (isResoraCollectionLike(value)) return normalizeSerializableData(value.toObject());
|
|
468
480
|
if (isArkormLikeModel(value)) return normalizeSerializableData(value.toObject());
|
|
469
481
|
if (isArkormLikeCollection(value)) {
|
|
470
482
|
const collectionData = value.all();
|
|
@@ -974,12 +986,12 @@ const resolveAndApply = (imported) => {
|
|
|
974
986
|
* @returns
|
|
975
987
|
*/
|
|
976
988
|
const loadRuntimeConfigSync = () => {
|
|
977
|
-
const
|
|
989
|
+
const req = (0, module$1.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
978
990
|
const syncConfigPaths = [path.default.join(process.cwd(), "resora.config.cjs")];
|
|
979
991
|
for (const configPath of syncConfigPaths) {
|
|
980
992
|
if (!(0, fs.existsSync)(configPath)) continue;
|
|
981
993
|
try {
|
|
982
|
-
resolveAndApply(
|
|
994
|
+
resolveAndApply(req(configPath));
|
|
983
995
|
return true;
|
|
984
996
|
} catch {
|
|
985
997
|
continue;
|
|
@@ -2062,11 +2074,19 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2062
2074
|
this.res = extractResponseFromCtx(ctx);
|
|
2063
2075
|
}
|
|
2064
2076
|
}
|
|
2077
|
+
getSourceData() {
|
|
2078
|
+
return Array.isArray(this.resource) ? this.resource : isArkormLikeCollection(this.resource) ? this.resource.all() : this.resource.data;
|
|
2079
|
+
}
|
|
2080
|
+
resolveObjectData() {
|
|
2081
|
+
let data = this.getSourceData();
|
|
2082
|
+
if (this.collects) data = data.map((item) => new this.collects(item).data());
|
|
2083
|
+
return normalizeSerializableData(data);
|
|
2084
|
+
}
|
|
2065
2085
|
/**
|
|
2066
2086
|
* Get the original resource data
|
|
2067
2087
|
*/
|
|
2068
2088
|
data() {
|
|
2069
|
-
return this.
|
|
2089
|
+
return this.getSourceData();
|
|
2070
2090
|
}
|
|
2071
2091
|
/**
|
|
2072
2092
|
* Get the current serialized output body.
|
|
@@ -2146,7 +2166,7 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2146
2166
|
if (!this.called.json) {
|
|
2147
2167
|
this.called.json = true;
|
|
2148
2168
|
let data = this.data();
|
|
2149
|
-
if (this.collects) data = data.map((item) => new this.collects(item).data());
|
|
2169
|
+
if (this.collects && this.data === ResourceCollection.prototype.data) data = data.map((item) => new this.collects(item).data());
|
|
2150
2170
|
data = normalizeSerializableData(data);
|
|
2151
2171
|
data = sanitizeConditionalAttributes(data);
|
|
2152
2172
|
const paginationExtras = !Array.isArray(this.resource) ? buildPaginationExtras(this.resource) : {};
|
|
@@ -2187,8 +2207,7 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2187
2207
|
*/
|
|
2188
2208
|
toObject() {
|
|
2189
2209
|
this.called.toObject = true;
|
|
2190
|
-
this.
|
|
2191
|
-
return normalizeSerializableData(Array.isArray(this.resource) ? this.resource : isArkormLikeCollection(this.resource) ? this.resource.all() : this.resource.data);
|
|
2210
|
+
return this.resolveObjectData();
|
|
2192
2211
|
}
|
|
2193
2212
|
/**
|
|
2194
2213
|
* Convert resource to object format and return original data.
|
|
@@ -2687,6 +2706,7 @@ exports.hasPaginationLink = hasPaginationLink;
|
|
|
2687
2706
|
exports.isArkormLikeCollection = isArkormLikeCollection;
|
|
2688
2707
|
exports.isArkormLikeModel = isArkormLikeModel;
|
|
2689
2708
|
exports.isPlainObject = isPlainObject;
|
|
2709
|
+
exports.isResoraCollectionLike = isResoraCollectionLike;
|
|
2690
2710
|
exports.loadRuntimeConfig = loadRuntimeConfig;
|
|
2691
2711
|
exports.mergeMetadata = mergeMetadata;
|
|
2692
2712
|
exports.normalizeSerializableData = normalizeSerializableData;
|
package/dist/index.d.cts
CHANGED
|
@@ -736,6 +736,8 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
736
736
|
isPaginatedCollectible(value: unknown): value is Collectible;
|
|
737
737
|
constructor(rsc: R);
|
|
738
738
|
constructor(rsc: R, ctx: Response | H3Event | Record<string, any>);
|
|
739
|
+
private getSourceData;
|
|
740
|
+
private resolveObjectData;
|
|
739
741
|
/**
|
|
740
742
|
* Get the original resource data
|
|
741
743
|
*/
|
|
@@ -1216,6 +1218,12 @@ type ArkormLikeModel = {
|
|
|
1216
1218
|
type ArkormLikeCollection = {
|
|
1217
1219
|
all: () => unknown;
|
|
1218
1220
|
};
|
|
1221
|
+
type ResoraCollectionLike = {
|
|
1222
|
+
toObject: () => unknown;
|
|
1223
|
+
getBody: () => unknown;
|
|
1224
|
+
json: () => unknown;
|
|
1225
|
+
setCollects: (...args: unknown[]) => unknown;
|
|
1226
|
+
};
|
|
1219
1227
|
/**
|
|
1220
1228
|
* Type guard to check if a value is an Arkorm-like model, which is defined as an object
|
|
1221
1229
|
* that has a toObject method and optionally getRawAttributes, getAttribute, and
|
|
@@ -1232,6 +1240,13 @@ declare const isArkormLikeModel: (value: unknown) => value is ArkormLikeModel;
|
|
|
1232
1240
|
* @returns
|
|
1233
1241
|
*/
|
|
1234
1242
|
declare const isArkormLikeCollection: (value: unknown) => value is ArkormLikeCollection;
|
|
1243
|
+
/**
|
|
1244
|
+
* Type guard to check if a value is a Resora collection-like serializer.
|
|
1245
|
+
*
|
|
1246
|
+
* @param value
|
|
1247
|
+
* @returns
|
|
1248
|
+
*/
|
|
1249
|
+
declare const isResoraCollectionLike: (value: unknown) => value is ResoraCollectionLike;
|
|
1235
1250
|
/**
|
|
1236
1251
|
* Normalize a value for serialization by recursively converting Arkorm-like models and
|
|
1237
1252
|
* collections to plain objects, while preserving the structure of arrays and plain objects.
|
|
@@ -1573,4 +1588,4 @@ declare const extractResponseFromCtx: (ctx: unknown) => any | undefined;
|
|
|
1573
1588
|
*/
|
|
1574
1589
|
declare const setCtx: (ctx: unknown) => void;
|
|
1575
1590
|
//#endregion
|
|
1576
|
-
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
|
1591
|
+
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, isResoraCollectionLike, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
package/dist/index.d.mts
CHANGED
|
@@ -736,6 +736,8 @@ declare class ResourceCollection<R extends ResourceData[] | Collectible | Collec
|
|
|
736
736
|
isPaginatedCollectible(value: unknown): value is Collectible;
|
|
737
737
|
constructor(rsc: R);
|
|
738
738
|
constructor(rsc: R, ctx: Response | H3Event | Record<string, any>);
|
|
739
|
+
private getSourceData;
|
|
740
|
+
private resolveObjectData;
|
|
739
741
|
/**
|
|
740
742
|
* Get the original resource data
|
|
741
743
|
*/
|
|
@@ -1216,6 +1218,12 @@ type ArkormLikeModel = {
|
|
|
1216
1218
|
type ArkormLikeCollection = {
|
|
1217
1219
|
all: () => unknown;
|
|
1218
1220
|
};
|
|
1221
|
+
type ResoraCollectionLike = {
|
|
1222
|
+
toObject: () => unknown;
|
|
1223
|
+
getBody: () => unknown;
|
|
1224
|
+
json: () => unknown;
|
|
1225
|
+
setCollects: (...args: unknown[]) => unknown;
|
|
1226
|
+
};
|
|
1219
1227
|
/**
|
|
1220
1228
|
* Type guard to check if a value is an Arkorm-like model, which is defined as an object
|
|
1221
1229
|
* that has a toObject method and optionally getRawAttributes, getAttribute, and
|
|
@@ -1232,6 +1240,13 @@ declare const isArkormLikeModel: (value: unknown) => value is ArkormLikeModel;
|
|
|
1232
1240
|
* @returns
|
|
1233
1241
|
*/
|
|
1234
1242
|
declare const isArkormLikeCollection: (value: unknown) => value is ArkormLikeCollection;
|
|
1243
|
+
/**
|
|
1244
|
+
* Type guard to check if a value is a Resora collection-like serializer.
|
|
1245
|
+
*
|
|
1246
|
+
* @param value
|
|
1247
|
+
* @returns
|
|
1248
|
+
*/
|
|
1249
|
+
declare const isResoraCollectionLike: (value: unknown) => value is ResoraCollectionLike;
|
|
1235
1250
|
/**
|
|
1236
1251
|
* Normalize a value for serialization by recursively converting Arkorm-like models and
|
|
1237
1252
|
* collections to plain objects, while preserving the structure of arrays and plain objects.
|
|
@@ -1573,4 +1588,4 @@ declare const extractResponseFromCtx: (ctx: unknown) => any | undefined;
|
|
|
1573
1588
|
*/
|
|
1574
1589
|
declare const setCtx: (ctx: unknown) => void;
|
|
1575
1590
|
//#endregion
|
|
1576
|
-
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
|
1591
|
+
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CaseStyle, CliApp, Collectible, CollectionBody, CollectionLike, Config, Cursor, GenericBody, GenericResource, InitCommand, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, PaginatorLike, ResoraConfig, ResoraPlugin, ResoraPluginApi, ResoraPluginUtility, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResourceLevelConfig, ResponseData, ResponseDataCollection, ResponseFactory, ResponseFactoryContext, ResponseKind, ResponsePluginEvent, ResponseStructureConfig, SendPluginEvent, SerializePluginEvent, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, isResoraCollectionLike, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
package/dist/index.mjs
CHANGED
|
@@ -428,6 +428,17 @@ const isArkormLikeCollection = (value) => {
|
|
|
428
428
|
return typeof value.all === "function";
|
|
429
429
|
};
|
|
430
430
|
/**
|
|
431
|
+
* Type guard to check if a value is a Resora collection-like serializer.
|
|
432
|
+
*
|
|
433
|
+
* @param value
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
436
|
+
const isResoraCollectionLike = (value) => {
|
|
437
|
+
if (!value || typeof value !== "object") return false;
|
|
438
|
+
const candidate = value;
|
|
439
|
+
return typeof candidate.toObject === "function" && typeof candidate.getBody === "function" && typeof candidate.json === "function" && typeof candidate.setCollects === "function";
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
431
442
|
* Normalize a value for serialization by recursively converting Arkorm-like models and
|
|
432
443
|
* collections to plain objects, while preserving the structure of arrays and plain objects.
|
|
433
444
|
*
|
|
@@ -436,6 +447,7 @@ const isArkormLikeCollection = (value) => {
|
|
|
436
447
|
*/
|
|
437
448
|
const normalizeSerializableData = (value) => {
|
|
438
449
|
if (Array.isArray(value)) return value.map((item) => normalizeSerializableData(item));
|
|
450
|
+
if (isResoraCollectionLike(value)) return normalizeSerializableData(value.toObject());
|
|
439
451
|
if (isArkormLikeModel(value)) return normalizeSerializableData(value.toObject());
|
|
440
452
|
if (isArkormLikeCollection(value)) {
|
|
441
453
|
const collectionData = value.all();
|
|
@@ -945,12 +957,12 @@ const resolveAndApply = (imported) => {
|
|
|
945
957
|
* @returns
|
|
946
958
|
*/
|
|
947
959
|
const loadRuntimeConfigSync = () => {
|
|
948
|
-
const
|
|
960
|
+
const req = createRequire(import.meta.url);
|
|
949
961
|
const syncConfigPaths = [path.join(process.cwd(), "resora.config.cjs")];
|
|
950
962
|
for (const configPath of syncConfigPaths) {
|
|
951
963
|
if (!existsSync(configPath)) continue;
|
|
952
964
|
try {
|
|
953
|
-
resolveAndApply(
|
|
965
|
+
resolveAndApply(req(configPath));
|
|
954
966
|
return true;
|
|
955
967
|
} catch {
|
|
956
968
|
continue;
|
|
@@ -2033,11 +2045,19 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2033
2045
|
this.res = extractResponseFromCtx(ctx);
|
|
2034
2046
|
}
|
|
2035
2047
|
}
|
|
2048
|
+
getSourceData() {
|
|
2049
|
+
return Array.isArray(this.resource) ? this.resource : isArkormLikeCollection(this.resource) ? this.resource.all() : this.resource.data;
|
|
2050
|
+
}
|
|
2051
|
+
resolveObjectData() {
|
|
2052
|
+
let data = this.getSourceData();
|
|
2053
|
+
if (this.collects) data = data.map((item) => new this.collects(item).data());
|
|
2054
|
+
return normalizeSerializableData(data);
|
|
2055
|
+
}
|
|
2036
2056
|
/**
|
|
2037
2057
|
* Get the original resource data
|
|
2038
2058
|
*/
|
|
2039
2059
|
data() {
|
|
2040
|
-
return this.
|
|
2060
|
+
return this.getSourceData();
|
|
2041
2061
|
}
|
|
2042
2062
|
/**
|
|
2043
2063
|
* Get the current serialized output body.
|
|
@@ -2117,7 +2137,7 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2117
2137
|
if (!this.called.json) {
|
|
2118
2138
|
this.called.json = true;
|
|
2119
2139
|
let data = this.data();
|
|
2120
|
-
if (this.collects) data = data.map((item) => new this.collects(item).data());
|
|
2140
|
+
if (this.collects && this.data === ResourceCollection.prototype.data) data = data.map((item) => new this.collects(item).data());
|
|
2121
2141
|
data = normalizeSerializableData(data);
|
|
2122
2142
|
data = sanitizeConditionalAttributes(data);
|
|
2123
2143
|
const paginationExtras = !Array.isArray(this.resource) ? buildPaginationExtras(this.resource) : {};
|
|
@@ -2158,8 +2178,7 @@ var ResourceCollection = class ResourceCollection extends BaseSerializer {
|
|
|
2158
2178
|
*/
|
|
2159
2179
|
toObject() {
|
|
2160
2180
|
this.called.toObject = true;
|
|
2161
|
-
this.
|
|
2162
|
-
return normalizeSerializableData(Array.isArray(this.resource) ? this.resource : isArkormLikeCollection(this.resource) ? this.resource.all() : this.resource.data);
|
|
2181
|
+
return this.resolveObjectData();
|
|
2163
2182
|
}
|
|
2164
2183
|
/**
|
|
2165
2184
|
* Convert resource to object format and return original data.
|
|
@@ -2618,4 +2637,4 @@ var Resource = class Resource extends BaseSerializer {
|
|
|
2618
2637
|
};
|
|
2619
2638
|
|
|
2620
2639
|
//#endregion
|
|
2621
|
-
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CliApp, GenericResource, InitCommand, MakeResource, Resource, ResourceCollection, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
|
2640
|
+
export { ApiResource, CONDITIONAL_ATTRIBUTE_MISSING, CliApp, GenericResource, InitCommand, MakeResource, Resource, ResourceCollection, ServerResponse, appendRootProperties, applyRuntimeConfig, buildPaginationExtras, buildResponseEnvelope, createArkormCurrentPageResolver, defineConfig, definePlugin, extractRequestUrl, extractResponseFromCtx, getCaseTransformer, getCtx, getDefaultConfig, getGlobalBaseUrl, getGlobalCase, getGlobalCursorMeta, getGlobalPageName, getGlobalPaginatedExtras, getGlobalPaginatedLinks, getGlobalPaginatedMeta, getGlobalResponseFactory, getGlobalResponseRootKey, getGlobalResponseStructure, getGlobalResponseWrap, getPaginationExtraKeys, getRegisteredPlugins, getRequestUrl, getUtility, hasPaginationLink, isArkormLikeCollection, isArkormLikeModel, isPlainObject, isResoraCollectionLike, loadRuntimeConfig, mergeMetadata, normalizeSerializableData, registerPlugin, registerUtility, resetPluginsForTests, resetRuntimeConfigForTests, resolveCurrentPage, resolveMergeWhen, resolveWhen, resolveWhenNotNull, resolveWithHookMetadata, runPluginHook, runWithCtx, sanitizeConditionalAttributes, setCtx, setGlobalBaseUrl, setGlobalCase, setGlobalCursorMeta, setGlobalPageName, setGlobalPaginatedExtras, setGlobalPaginatedLinks, setGlobalPaginatedMeta, setGlobalResponseFactory, setGlobalResponseRootKey, setGlobalResponseStructure, setGlobalResponseWrap, setRequestUrl, splitWords, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, transformKeys };
|
package/package.json
CHANGED