@fjell/client-api 4.4.58 → 4.4.60

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.js CHANGED
@@ -35,18 +35,38 @@ var getAllOperation = (api, apiOptions, utilities) => {
35
35
  utilities.getPath(loc),
36
36
  requestOptions
37
37
  );
38
- const processedItems = await utilities.processArray(Promise.resolve(result.items));
38
+ let itemsArray = [];
39
+ if (result) {
40
+ if (result.items && Array.isArray(result.items)) {
41
+ itemsArray = result.items;
42
+ } else if (Array.isArray(result)) {
43
+ itemsArray = result;
44
+ } else {
45
+ logger.warning("Unexpected response format from server", {
46
+ result,
47
+ resultType: typeof result,
48
+ hasItems: "items" in result,
49
+ resultKeys: result && typeof result === "object" ? Object.keys(result) : []
50
+ });
51
+ itemsArray = [];
52
+ }
53
+ }
54
+ if (!Array.isArray(itemsArray)) {
55
+ logger.error("itemsArray is not an array, defaulting to empty array", { itemsArray });
56
+ itemsArray = [];
57
+ }
58
+ const processedItems = await utilities.processArray(Promise.resolve(itemsArray));
39
59
  logger.debug("QUERY_CACHE: client-api.all() - API response received", {
40
60
  query: JSON.stringify(query),
41
61
  locations: JSON.stringify(locations),
42
62
  itemCount: processedItems.length,
43
- total: result.metadata?.total,
44
- hasMore: result.metadata?.hasMore,
63
+ total: result?.metadata?.total,
64
+ hasMore: result?.metadata?.hasMore,
45
65
  itemKeys: processedItems.map((item) => JSON.stringify(item.key))
46
66
  });
47
67
  return {
48
68
  items: processedItems,
49
- metadata: result.metadata
69
+ metadata: result?.metadata || { total: 0, returned: 0, offset: 0, hasMore: false }
50
70
  };
51
71
  };
52
72
  return all;
@@ -562,34 +582,44 @@ var getRemoveOperation = (api, apiOptions, utilities) => {
562
582
  // src/ops/find.ts
563
583
  var logger10 = logger_default.get("client-api", "ops", "find");
564
584
  var getFindOperation = (api, apiOptions, utilities) => {
565
- const find = async (finder, finderParams = {}, locations = []) => {
585
+ const find = async (finder, finderParams = {}, locations = [], findOptions) => {
566
586
  utilities.verifyLocations(locations);
567
587
  const loc = locations;
568
588
  const mergedParams = finderToParams(finder, finderParams);
589
+ if (findOptions?.limit != null) {
590
+ mergedParams.limit = findOptions.limit.toString();
591
+ }
592
+ if (findOptions?.offset != null) {
593
+ mergedParams.offset = findOptions.offset.toString();
594
+ }
569
595
  const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params: mergedParams });
570
- logger10.default("find", { finder, finderParams, locations, requestOptions });
596
+ logger10.default("find", { finder, finderParams, locations, findOptions, requestOptions });
571
597
  logger10.debug("QUERY_CACHE: client-api.find() - Making API request", {
572
598
  finder,
573
599
  finderParams: JSON.stringify(finderParams),
574
600
  locations: JSON.stringify(locations),
601
+ findOptions,
575
602
  path: utilities.getPath(loc),
576
603
  params: JSON.stringify(mergedParams),
577
604
  isAuthenticated: apiOptions.allAuthenticated
578
605
  });
579
- const result = await utilities.processArray(
580
- api.httpGet(
581
- utilities.getPath(loc),
582
- requestOptions
583
- )
606
+ const response = await api.httpGet(
607
+ utilities.getPath(loc),
608
+ requestOptions
584
609
  );
610
+ const processedItems = await utilities.processArray(Promise.resolve(response.items || []));
585
611
  logger10.debug("QUERY_CACHE: client-api.find() - API response received", {
586
612
  finder,
587
613
  finderParams: JSON.stringify(finderParams),
588
614
  locations: JSON.stringify(locations),
589
- itemCount: result.length,
590
- itemKeys: result.map((item) => JSON.stringify(item.key))
615
+ itemCount: processedItems.length,
616
+ total: response.metadata?.total || 0,
617
+ itemKeys: processedItems.map((item) => JSON.stringify(item.key))
591
618
  });
592
- return result;
619
+ return {
620
+ items: processedItems,
621
+ metadata: response.metadata
622
+ };
593
623
  };
594
624
  return find;
595
625
  };
@@ -947,12 +977,58 @@ var createAItemAPI = (api, pkType, pathNames, options) => {
947
977
 
948
978
  // src/CItemAPI.ts
949
979
  var logger16 = logger_default.get("CItemAPI");
980
+ function ensureItemsExtracted(result, operationName) {
981
+ if (result && typeof result === "object" && Array.isArray(result.items)) {
982
+ return result;
983
+ }
984
+ if (result && typeof result === "object" && "items" in result && "metadata" in result) {
985
+ logger16.debug(`${operationName}: Extracting items from response structure`, {
986
+ hasItems: Array.isArray(result.items),
987
+ itemsType: typeof result.items,
988
+ itemsLength: Array.isArray(result.items) ? result.items.length : "N/A"
989
+ });
990
+ return {
991
+ items: Array.isArray(result.items) ? result.items : [],
992
+ metadata: result.metadata || {}
993
+ };
994
+ }
995
+ if (Array.isArray(result)) {
996
+ logger16.debug(`${operationName}: Wrapping array result in { items, metadata } structure`);
997
+ return {
998
+ items: result,
999
+ metadata: {
1000
+ total: result.length,
1001
+ returned: result.length,
1002
+ offset: 0,
1003
+ hasMore: false
1004
+ }
1005
+ };
1006
+ }
1007
+ logger16.warning(`${operationName}: Unexpected response format, returning empty result`, {
1008
+ resultType: typeof result,
1009
+ resultKeys: result && typeof result === "object" ? Object.keys(result) : []
1010
+ });
1011
+ return {
1012
+ items: [],
1013
+ metadata: {}
1014
+ };
1015
+ }
950
1016
  var createCItemApi = (api, type, pathNames, options) => {
951
1017
  logger16.default("createCItemApi", { api, type, pathNames, options });
952
1018
  const aItemAPI = createAItemAPI(api, type, pathNames, options);
1019
+ const all = async (query, locations, allOptions) => {
1020
+ const result = allOptions != null ? await aItemAPI.all(query, locations, allOptions) : await aItemAPI.all(query, locations);
1021
+ const extracted = ensureItemsExtracted(result, "all");
1022
+ return extracted;
1023
+ };
1024
+ const find = async (finder, finderParams, locations, findOptions) => {
1025
+ const result = findOptions != null ? await aItemAPI.find(finder, finderParams, locations, findOptions) : await aItemAPI.find(finder, finderParams, locations);
1026
+ const extracted = ensureItemsExtracted(result, "find");
1027
+ return extracted;
1028
+ };
953
1029
  return {
954
1030
  action: aItemAPI.action,
955
- all: aItemAPI.all,
1031
+ all,
956
1032
  allAction: aItemAPI.allAction,
957
1033
  allFacet: aItemAPI.allFacet,
958
1034
  one: aItemAPI.one,
@@ -962,18 +1038,58 @@ var createCItemApi = (api, type, pathNames, options) => {
962
1038
  update: aItemAPI.update,
963
1039
  upsert: aItemAPI.upsert,
964
1040
  facet: aItemAPI.facet,
965
- find: aItemAPI.find,
1041
+ find,
966
1042
  findOne: aItemAPI.findOne
967
1043
  };
968
1044
  };
969
1045
 
970
1046
  // src/PItemAPI.ts
971
1047
  var logger17 = logger_default.get("PItemAPI");
1048
+ function ensureItemsExtracted2(result, operationName) {
1049
+ if (result && typeof result === "object" && Array.isArray(result.items)) {
1050
+ return result;
1051
+ }
1052
+ if (result && typeof result === "object" && "items" in result && "metadata" in result) {
1053
+ logger17.debug(`${operationName}: Extracting items from response structure`, {
1054
+ hasItems: Array.isArray(result.items),
1055
+ itemsType: typeof result.items,
1056
+ itemsLength: Array.isArray(result.items) ? result.items.length : "N/A"
1057
+ });
1058
+ return {
1059
+ items: Array.isArray(result.items) ? result.items : [],
1060
+ metadata: result.metadata || {}
1061
+ };
1062
+ }
1063
+ if (Array.isArray(result)) {
1064
+ logger17.debug(`${operationName}: Wrapping array result in { items, metadata } structure`);
1065
+ return {
1066
+ items: result,
1067
+ metadata: {
1068
+ total: result.length,
1069
+ returned: result.length,
1070
+ offset: 0,
1071
+ hasMore: false
1072
+ }
1073
+ };
1074
+ }
1075
+ logger17.warning(`${operationName}: Unexpected response format, returning empty result`, {
1076
+ resultType: typeof result,
1077
+ resultKeys: result && typeof result === "object" ? Object.keys(result) : []
1078
+ });
1079
+ return {
1080
+ items: [],
1081
+ metadata: {}
1082
+ };
1083
+ }
972
1084
  var createPItemApi = (api, type, pathName, options) => {
973
1085
  logger17.default("createPItemApi", { type, pathName, options });
974
1086
  const aItemAPI = createAItemAPI(api, type, [pathName], options);
975
1087
  const action = async (ik, action2, params) => await aItemAPI.action(ik, action2, params);
976
- const all = async (query, locations, allOptions) => await aItemAPI.all(query || {}, locations || [], allOptions);
1088
+ const all = async (query, locations, allOptions) => {
1089
+ const result = await aItemAPI.all(query || {}, locations || [], allOptions);
1090
+ const extracted = ensureItemsExtracted2(result, "all");
1091
+ return extracted;
1092
+ };
977
1093
  const allAction = async (action2, params) => await aItemAPI.allAction(action2, params, []);
978
1094
  const allFacet = async (facet2, params) => await aItemAPI.allFacet(facet2, params);
979
1095
  const one = async (query) => await aItemAPI.one(query || {}, []);
@@ -983,7 +1099,11 @@ var createPItemApi = (api, type, pathName, options) => {
983
1099
  const update = async (ik, item) => await aItemAPI.update(ik, item);
984
1100
  const upsert = async (ik, item, locations) => await aItemAPI.upsert(ik, item, locations);
985
1101
  const facet = async (ik, facet2, params) => await aItemAPI.facet(ik, facet2, params);
986
- const find = async (finder, finderParams) => await aItemAPI.find(finder, finderParams);
1102
+ const find = async (finder, finderParams, locations, findOptions) => {
1103
+ const result = await aItemAPI.find(finder, finderParams, locations || [], findOptions);
1104
+ const extracted = ensureItemsExtracted2(result, "find");
1105
+ return extracted;
1106
+ };
987
1107
  const findOne = async (finder, finderParams) => await aItemAPI.findOne(finder, finderParams);
988
1108
  return {
989
1109
  action,
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/ops/all.ts", "../src/logger.ts", "../src/ops/action.ts", "../src/ops/allAction.ts", "../src/ops/one.ts", "../src/ops/errorHandling.ts", "../src/ops/create.ts", "../src/ops/update.ts", "../src/ops/upsert.ts", "../src/ops/get.ts", "../src/ops/remove.ts", "../src/ops/find.ts", "../src/ops/findOne.ts", "../src/ops/facet.ts", "../src/ops/allFacet.ts", "../src/ops/index.ts", "../src/Utilities.ts", "../src/AItemAPI.ts", "../src/CItemAPI.ts", "../src/PItemAPI.ts", "../src/Instance.ts", "../src/InstanceFactory.ts", "../src/Registry.ts", "../src/errors/index.ts", "../src/index.ts", "../src/http/HttpWrapper.ts"],
4
- "sourcesContent": ["import {\n AllMethod,\n AllOperationResult,\n AllOptions,\n Item,\n ItemQuery,\n LocKeyArray,\n queryToParams,\n} from \"@fjell/core\";\nimport { HttpApi, QueryParams } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'all');\n\nexport const getAllOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): AllMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const all = async (\n query: ItemQuery = {} as ItemQuery,\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = [],\n allOptions?: AllOptions\n ): Promise<AllOperationResult<V>> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // Build query params from ItemQuery\n const params: QueryParams = queryToParams(query);\n \n // Override with AllOptions if provided (takes precedence)\n if (allOptions && 'limit' in allOptions && allOptions.limit != null) {\n params.limit = String(allOptions.limit);\n }\n if (allOptions && 'offset' in allOptions && allOptions.offset != null) {\n params.offset = String(allOptions.offset);\n }\n\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params });\n\n logger.default('all', { query, locations, allOptions, requestOptions });\n logger.debug('QUERY_CACHE: client-api.all() - Making API request', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n allOptions: JSON.stringify(allOptions),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n // Server returns AllOperationResult<V> with items and metadata\n const result = await api.httpGet<AllOperationResult<V>>(\n utilities.getPath(loc),\n requestOptions,\n );\n\n // Process items through utilities (date conversion, validation, etc.)\n const processedItems = await utilities.processArray(Promise.resolve(result.items));\n \n logger.debug('QUERY_CACHE: client-api.all() - API response received', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n itemCount: processedItems.length,\n total: result.metadata?.total,\n hasMore: result.metadata?.hasMore,\n itemKeys: processedItems.map(item => JSON.stringify(item.key))\n });\n\n // Return AllOperationResult with processed items\n return {\n items: processedItems,\n metadata: result.metadata\n };\n }\n\n return all;\n}\n\n", "import Logging from '@fjell/logging';\n\nconst LibLogger = Logging.getLogger('@fjell/client-api');\n\nexport default LibLogger;\n", "import { ActionOperationMethod, ComKey, Item, LocKeyArray, OperationParams, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'action');\n\nexport const getActionOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ): ActionOperationMethod<V, S, L1, L2, L3, L4, L5> => {\n const action = async (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n action: string,\n params?: OperationParams,\n ): Promise<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]> => {\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('action', { ik, action, params, requestOptions });\n\n const response = await api.httpPost<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>(\n `${utilities.getPath(ik)}/${action}`,\n params || {},\n requestOptions,\n );\n\n const [item, affectedItems] = response;\n return [\n await utilities.processOne(Promise.resolve(item)),\n affectedItems\n ];\n };\n return action;\n}\n", " \nimport { AllActionOperationMethod, ComKey, Item, LocKeyArray, OperationParams, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'allAction');\n\nexport const getAllActionOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ): AllActionOperationMethod<V, S, L1, L2, L3, L4, L5> => {\n const allAction = async (\n action: string,\n params?: OperationParams,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ): Promise<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]> => {\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations || [];\n logger.default('allAction', { action, params, locations: loc, requestOptions });\n utilities.verifyLocations(loc);\n\n const response = await api.httpPost<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>(\n `${utilities.getPath(loc)}/${action}`,\n params || {},\n requestOptions,\n );\n\n // Handle edge cases where response might not be an array\n let items: V[] = [];\n let affectedItems: Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>> = [];\n\n if (Array.isArray(response)) {\n // Check if this is a properly formatted tuple response [items, affectedItems]\n if (response.length === 2 && Array.isArray(response[0])) {\n [items, affectedItems] = response;\n } else {\n // Handle other array responses - return as-is\n return response as any;\n }\n } else if (response && typeof response === 'object' && Object.keys(response).length === 0) {\n // Handle empty object response {}\n items = [];\n affectedItems = [];\n } else if (typeof response === 'string' && response === '{}') {\n // Handle string response \"{}\"\n items = [];\n affectedItems = [];\n }\n\n const processedItems = await utilities.processArray(Promise.resolve(items));\n if (Array.isArray(processedItems)) {\n processedItems.forEach(item => utilities.validatePK(item));\n }\n return [\n processedItems,\n affectedItems\n ];\n };\n return allAction;\n}\n", "import {\n AllOperationResult,\n Item,\n ItemQuery,\n LocKeyArray,\n OneMethod,\n QueryParams,\n queryToParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'one');\n\nexport const getOneOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): OneMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const one = async (\n query: ItemQuery = {} as ItemQuery,\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V | null> => {\n utilities.verifyLocations(locations);\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // Add limit: 1 to optimize the query\n const params: QueryParams = queryToParams(query);\n params.limit = '1';\n \n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.readAuthenticated, params });\n logger.default('one', { query, locations, requestOptions });\n logger.debug('QUERY_CACHE: client-api.one() - Making API request', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.readAuthenticated\n });\n\n // Server returns AllOperationResult<V> with items and metadata\n const result = await api.httpGet<AllOperationResult<V>>(\n utilities.getPath(loc),\n requestOptions,\n );\n\n // Process items through utilities (date conversion, validation, etc.)\n const items = await utilities.processArray(Promise.resolve(result.items));\n\n let item: V | null = null;\n if (items.length > 0) {\n item = items[0];\n logger.debug('QUERY_CACHE: client-api.one() - API response received', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n itemKey: JSON.stringify(item.key)\n });\n } else {\n logger.debug('QUERY_CACHE: client-api.one() - API returned no items', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations)\n });\n }\n\n return item;\n }\n\n return one;\n}\n", "/**\n * Shared error handling utilities for all HTTP operations\n */\n\nimport { isFjellHttpError } from '@fjell/http-api';\n\n/**\n * Determines if an error should be retried based on error type and status code\n */\nexport function shouldRetryError(error: any): boolean {\n // Check FjellHttpError retryable flag first\n if (isFjellHttpError(error)) {\n return error.isRetryable();\n }\n\n // Retry on network errors and timeouts\n if (error.code === 'ECONNREFUSED' ||\n error.code === 'ENOTFOUND' ||\n error.code === 'ENETUNREACH' ||\n error.message?.includes('timeout') ||\n error.message?.includes('network')) {\n return true;\n }\n\n // Retry on HTTP 5xx errors and 429 (rate limiting)\n if (error.status >= 500 || error.status === 429) {\n return true;\n }\n\n // Don't retry on 4xx client errors (except 429)\n if (error.status >= 400 && error.status < 500 && error.status !== 429) {\n return false;\n }\n\n // Default to retrying unknown errors\n return true;\n}\n\n/**\n * Calculates retry delay with exponential backoff and jitter\n */\nexport function calculateRetryDelay(attempt: number, config: any): number {\n const exponentialDelay = (config.initialDelayMs || 1000) * Math.pow(config.backoffMultiplier || 2, attempt);\n const cappedDelay = Math.min(exponentialDelay, config.maxDelayMs || 30000);\n\n // Add jitter: random value between 50% and 100% of calculated delay\n const jitter = 0.5 + (Math.random() * 0.5);\n return Math.floor(cappedDelay * jitter);\n}\n\n/**\n * Enhances error with additional context information\n * Preserves FjellHttpError without modification\n */\nexport function enhanceError(error: any, context: any): any {\n if (!error) return new Error('Unknown error occurred');\n\n // Don't modify FjellHttpError - it already has full context\n if (isFjellHttpError(error)) {\n return error;\n }\n\n // If it's already enhanced, return as-is\n if (error.context) return error;\n\n // Add context to the error\n const enhancedError = new Error(error.message || 'HTTP operation failed');\n Object.assign(enhancedError, {\n code: error.code || error.status || 'UNKNOWN_ERROR',\n status: error.status,\n context,\n originalError: error\n });\n\n return enhancedError;\n}\n\n/**\n * Gets default retry configuration merged with provided options\n */\nexport function getRetryConfig(apiOptions: any): any {\n return {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n}\n\n/**\n * Handles custom error handler execution with error protection\n */\nexport function executeErrorHandler(\n errorHandler: ((error: any, context?: Record<string, any>) => void) | undefined,\n error: any,\n context: any,\n logger: any\n): void {\n if (!errorHandler) return;\n\n try {\n errorHandler(error, context);\n } catch (handlerError: any) {\n logger.error('Custom error handler failed', {\n originalError: error.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n}\n\n/**\n * Common retry loop logic for HTTP operations\n */\nexport async function executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string,\n operationContext: Record<string, any>,\n apiOptions: any,\n logger: any,\n specialErrorHandling?: (error: any) => T | null | undefined\n): Promise<T> {\n const retryConfig = getRetryConfig(apiOptions);\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Executing ${operationName} (attempt ${attempt + 1})`, operationContext);\n\n const result = await operation();\n\n if (attempt > 0) {\n logger.info(`${operationName} operation succeeded after ${attempt} retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n\n // Handle special error cases (like 404 returning null)\n if (specialErrorHandling) {\n const specialResult = specialErrorHandling(error);\n if (specialResult !== void 0) {\n return specialResult as T;\n }\n }\n\n // Don't retry on the last attempt\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n // Check if we should retry this error\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug(`Not retrying ${operationName} operation due to non-retryable error`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n attempt: attempt + 1\n });\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`Retrying ${operationName} operation (attempt ${attempt + 2}) after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n delay,\n attemptNumber: attempt + 1\n });\n\n // Wait before retrying\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n // Handle final error\n const finalError = enhanceError(lastError, operationContext);\n\n // Execute custom error handler if provided\n executeErrorHandler(apiOptions.errorHandler, finalError, operationContext, logger);\n\n logger.error(`${operationName} operation failed after ${retryConfig.maxRetries + 1} attempts`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n duration: Date.now() - startTime,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n}\n", "import {\n CreateMethod,\n CreateOptions,\n Item,\n LocKeyArray\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\nimport { calculateRetryDelay, enhanceError, shouldRetryError } from \"./errorHandling\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'create');\n\nexport const getCreateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): CreateMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const create = async (\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n options?: CreateOptions<S, L1, L2, L3, L4, L5>\n ): Promise<V> => {\n // Extract locations or key from options for backward compatibility\n const locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = options?.locations || [];\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('create', { item, options, locations, requestOptions });\n utilities.verifyLocations(locations);\n \n // If a key was provided in options, include it in the item\n let itemToCreate = item;\n if (options?.key) {\n itemToCreate = { ...item, ...options.key };\n }\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n const operationContext = {\n operation: 'create',\n path: utilities.getPath(loc),\n itemType: typeof item,\n hasLocations: locations.length > 0\n };\n\n // Retry configuration from options or defaults\n const retryConfig = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Creating item (attempt ${attempt + 1})`, operationContext);\n\n const result = await utilities.processOne(api.httpPost<V>(\n utilities.getPath(loc),\n itemToCreate,\n requestOptions,\n ));\n\n utilities.validatePK(result);\n\n if (attempt > 0) {\n logger.info(`Create operation succeeded after ${attempt} retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n\n // Don't retry on the last attempt\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n // Determine if error is retryable\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug('Not retrying create operation due to non-retryable error', {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n attempt: attempt + 1\n });\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`Retrying create operation (attempt ${attempt + 2}) after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n delay,\n attemptNumber: attempt + 1\n });\n\n // Wait before retrying\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n // Handle final error\n const finalError = enhanceError(lastError, operationContext);\n\n // Call custom error handler if provided\n if (apiOptions.errorHandler) {\n try {\n apiOptions.errorHandler(finalError, operationContext);\n } catch (handlerError: any) {\n logger.error('Custom error handler failed', {\n originalError: finalError.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n }\n\n logger.error(`Create operation failed after ${retryConfig.maxRetries + 1} attempts`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n duration: Date.now() - startTime,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n };\n\n return create;\n}\n", "import {\n ComKey,\n Item,\n PriKey,\n UpdateMethod\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'update');\n\nexport const getUpdateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): UpdateMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const update = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('update', { ik, item, requestOptions });\n\n return await utilities.processOne(\n api.httpPut<V>(\n utilities.getPath(ik),\n item,\n requestOptions,\n ));\n }\n\n return update;\n}\n", "import {\n ComKey,\n Item,\n LocKeyArray,\n PriKey,\n UpdateOptions\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'upsert');\n\nexport const getUpsertOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ) => {\n\n const upsert = async (\n key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5>,\n options?: UpdateOptions\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('upsert', { key, item, locations, options, requestOptions });\n\n // Add locations to query params if provided\n const path = utilities.getPath(key);\n let url = locations && locations.length > 0\n ? `${path}?locations=${encodeURIComponent(JSON.stringify(locations))}`\n : path;\n\n // Add update options to query params if provided\n if (options) {\n const separator = url.includes('?') ? '&' : '?';\n url += `${separator}options=${encodeURIComponent(JSON.stringify(options))}`;\n }\n\n return await utilities.processOne(\n api.httpPut<V>(\n url,\n { ...item, upsert: true },\n requestOptions,\n ));\n }\n\n return upsert;\n}\n\n", "import {\n ComKey,\n GetMethod,\n Item,\n PriKey,\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\nimport { calculateRetryDelay, enhanceError, shouldRetryError } from \"./errorHandling\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'get');\n\nexport const getGetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): GetMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const get = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ): Promise<V | null> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.readAuthenticated });\n const keyStr = JSON.stringify(ik);\n \n logger.default('get', { ik, requestOptions });\n\n const operationContext = {\n operation: 'get',\n path: utilities.getPath(ik),\n keyType: typeof ik,\n key: keyStr\n };\n\n logger.debug('CLIENT_API: get() started', {\n ...operationContext,\n isAuthenticated: apiOptions.readAuthenticated\n });\n\n const retryConfig = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n const attemptStartTime = Date.now();\n try {\n logger.debug(`CLIENT_API: get() attempt ${attempt + 1}`, {\n ...operationContext,\n attempt: attempt + 1,\n maxRetries: retryConfig.maxRetries + 1\n });\n\n const httpStartTime = Date.now();\n const result = await utilities.processOne(\n api.httpGet<V>(\n utilities.getPath(ik),\n requestOptions,\n )\n );\n const httpDuration = Date.now() - httpStartTime;\n\n utilities.validatePK(result);\n\n const attemptDuration = Date.now() - attemptStartTime;\n const totalDuration = Date.now() - startTime;\n\n if (attempt > 0) {\n logger.info(`CLIENT_API: get() succeeded after retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n httpDuration,\n attemptDuration,\n totalDuration\n });\n } else {\n logger.debug(`CLIENT_API: get() succeeded (first attempt)`, {\n ...operationContext,\n httpDuration,\n totalDuration,\n hasResult: !!result\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n const attemptDuration = Date.now() - attemptStartTime;\n\n // Handle 404 errors specially - return null instead of throwing\n if (error.status === 404) {\n logger.debug('CLIENT_API: get() - item not found (404)', {\n ...operationContext,\n attemptDuration,\n totalDuration: Date.now() - startTime\n });\n return null;\n }\n\n logger.debug('CLIENT_API: get() attempt failed', {\n ...operationContext,\n attempt: attempt + 1,\n attemptDuration,\n errorStatus: error.status,\n errorCode: error.code,\n errorMessage: error.message\n });\n\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug('CLIENT_API: get() - not retrying (non-retryable error)', {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n errorStatus: error.status,\n attempt: attempt + 1,\n totalDuration: Date.now() - startTime\n });\n break;\n }\n\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`CLIENT_API: get() - retrying after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n errorStatus: error.status,\n delay,\n attemptNumber: attempt + 1,\n nextAttempt: attempt + 2,\n maxRetries: retryConfig.maxRetries + 1\n });\n\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n const finalError = enhanceError(lastError, operationContext);\n const totalDuration = Date.now() - startTime;\n\n if (apiOptions.errorHandler) {\n try {\n apiOptions.errorHandler(finalError, operationContext);\n } catch (handlerError: any) {\n logger.error('CLIENT_API: Custom error handler failed', {\n ...operationContext,\n originalError: finalError.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n }\n\n logger.error(`CLIENT_API: get() failed after all retries`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n errorStatus: finalError.status,\n totalDuration,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n }\n\n return get;\n}\n", "import {\n ComKey,\n Item,\n PriKey,\n RemoveMethod\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'remove');\n\nexport const getRemoveOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): RemoveMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const remove = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n ): Promise<V | void> => {\n const requestOptions = Object.assign({}, apiOptions.deleteOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('remove', { ik, requestOptions });\n\n const result = await api.httpDelete<V | boolean | void>(utilities.getPath(ik), requestOptions);\n \n // If result is a boolean, return void for compatibility\n if (typeof result === 'boolean') {\n return;\n }\n \n // Otherwise return the item (if the server returns it)\n return result as V | void;\n }\n\n return remove;\n}\n", "import {\n FindMethod,\n Item,\n LocKeyArray,\n QueryParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { finderToParams } from \"../AItemAPI\";\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'find');\n\nexport const getFindOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FindMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const find = async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V[]> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n const mergedParams: QueryParams = finderToParams(finder, finderParams);\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params: mergedParams });\n logger.default('find', { finder, finderParams, locations, requestOptions });\n logger.debug('QUERY_CACHE: client-api.find() - Making API request', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n path: utilities.getPath(loc),\n params: JSON.stringify(mergedParams),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n const result = await utilities.processArray(\n api.httpGet<V[]>(\n utilities.getPath(loc),\n requestOptions,\n ));\n \n logger.debug('QUERY_CACHE: client-api.find() - API response received', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n itemCount: result.length,\n itemKeys: result.map(item => JSON.stringify(item.key))\n });\n\n return result;\n }\n\n return find;\n}\n", "import {\n FindOneMethod,\n Item,\n LocKeyArray,\n QueryParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { finderToParams } from \"../AItemAPI\";\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'find');\n\nexport const getFindOneOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FindOneMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const findOne = async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n const params: QueryParams = finderToParams(finder, finderParams);\n params.one = true;\n\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params });\n logger.default('findOne', { finder, finderParams, locations, requestOptions });\n logger.debug('QUERY_CACHE: client-api.findOne() - Making API request', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n const results = await utilities.processArray(\n api.httpGet<V[]>(\n utilities.getPath(loc),\n requestOptions,\n ));\n \n const result = results[0];\n if (result) {\n utilities.validatePK(result);\n logger.debug('QUERY_CACHE: client-api.findOne() - API response received', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n itemKey: JSON.stringify(result.key)\n });\n } else {\n logger.debug('QUERY_CACHE: client-api.findOne() - API returned no items', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations)\n });\n }\n \n return result;\n }\n\n return findOne;\n}\n", "import {\n ComKey,\n FacetOperationMethod,\n Item,\n PriKey,\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'facet');\n\nexport const getFacetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FacetOperationMethod<S, L1, L2, L3, L4, L5> => {\n\n /**\n * Executes a facet operation on an item.\n *\n * A facet is a piece of information that is related to an item - it represents\n * a specific aspect or characteristic of the item. Unlike actions which may\n * return items or perform operations, facets are informational queries that\n * return data about a particular facet of an item.\n *\n * @param ik - The item key (composite or primary key) identifying the item\n * @param facet - The name of the facet to query\n * @param body - Optional request body for the facet operation\n * @param options - Optional HTTP request options\n * @returns Promise resolving to the facet data\n */\n const facet = async (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<any> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.writeAuthenticated, params });\n logger.default('facet', { ik, facet, requestOptions });\n\n return api.httpGet<any>(\n `${utilities.getPath(ik)}/${facet}`,\n requestOptions,\n );\n\n };\n\n return facet;\n}\n", "import {\n AllFacetOperationMethod,\n Item,\n LocKeyArray\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'allFacet');\n\nexport const getAllFacetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): AllFacetOperationMethod<L1, L2, L3, L4, L5> => {\n\n const allFacet = async (\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V[]> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.writeAuthenticated, params });\n logger.default('allFacet', { facet, locations, requestOptions });\n utilities.verifyLocations(locations);\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // TODO: This should respond to either a single object, or multiple objects in an array.\n return api.httpGet<V[]>(\n `${utilities.getPath(loc)}/${facet}`,\n requestOptions,\n )\n };\n\n return allFacet;\n}\n", "/* eslint-disable indent */\nimport { Item } from \"@fjell/core\"\nimport { getAllOperation } from \"./all\"\nimport { getActionOperation } from \"./action\"\nimport { Utilities } from \"../Utilities\"\nimport { HttpApi } from \"@fjell/http-api\"\nimport { getAllActionOperation } from \"./allAction\"\nimport { getOneOperation } from \"./one\"\nimport { getCreateOperation } from \"./create\"\nimport { getUpdateOperation } from \"./update\"\nimport { getUpsertOperation } from \"./upsert\"\nimport { getGetOperation } from \"./get\"\nimport { getRemoveOperation } from \"./remove\"\nimport { getFindOperation } from \"./find\"\nimport { ClientApiOptions } from \"../ClientApiOptions\"\nimport { ClientApi } from \"../ClientApi\"\nimport { getFindOneOperation } from \"./findOne\"\nimport { getFacetOperation } from \"./facet\"\nimport { getAllFacetOperation } from \"./allFacet\"\n\nexport const getOperations =\n <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>,\n\n ): ClientApi<V, S, L1, L2, L3, L4, L5> => {\n return {\n action: getActionOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n all: getAllOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n allAction: getAllActionOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n allFacet: getAllFacetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n create: getCreateOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n facet: getFacetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n findOne: getFindOneOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n find: getFindOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n get: getGetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n one: getOneOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n remove: getRemoveOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n update: getUpdateOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n upsert: getUpsertOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n }\n }", "import {\n ComKey,\n validatePK as coreValidatePK,\n generateKeyArray,\n isPriKey,\n Item,\n LocKey,\n LocKeyArray,\n PriKey,\n} from \"@fjell/core\";\n\nimport LibLogger from \"./logger\";\nimport deepmerge from \"deepmerge\";\n\nconst logger = LibLogger.get('client-api', 'Utility');\n\nexport interface Utilities<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> {\n verifyLocations: (locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never) => boolean;\n processOne: (apiCall: Promise<V>) => Promise<V>;\n processArray: (api: Promise<V[]>) => Promise<V[]>;\n convertDoc: (doc: V) => V;\n getPath: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | []) => string;\n validatePK: (item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]) =>\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[];\n}\n\nexport const createUtilities = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(pkType: S, pathNames: string[]): Utilities<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createUtilities', { pkType, pathNames });\n\n const verifyLocations = (\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never,\n ): boolean => {\n\n if (locations && locations.length < pathNames.length - 1) {\n throw new Error('Not enough locations for pathNames: locations:'\n + locations.length + ' pathNames:' + pathNames.length);\n }\n return true;\n }\n\n const processOne = async (\n apiCall: Promise<V>,\n ): Promise<V> => {\n logger.default('processOne', { apiCall });\n const response = await apiCall;\n logger.default('processOne response', {\n responseType: typeof response,\n hasData: !!response\n });\n return convertDoc(response);\n };\n\n const processArray = async (\n api: Promise<V[]>,\n ): Promise<V[]> => {\n logger.default('processArray', { api });\n const response = await api;\n logger.default('processArray response', {\n responseType: typeof response,\n isArray: Array.isArray(response),\n length: Array.isArray(response) ? response.length : 0\n });\n if (response && Array.isArray(response)) {\n return response.map((subjectChat: V) =>\n convertDoc(subjectChat),\n ) as unknown as V[];\n } else {\n logger.error('Response was not an array', { response });\n throw new Error('Response was not an array');\n }\n };\n\n const convertDoc = (doc: V): V => {\n logger.default('convertDoc', { doc });\n // console.log(JSON.stringify(doc, null, 2));\n if (doc && doc.events) {\n const events = doc.events;\n for (const key in events) {\n events[key] = deepmerge(events[key], { at: events[key].at ? new Date(events[key].at) : null });\n }\n\n return doc as unknown as V;\n } else {\n return doc;\n }\n };\n\n const getPath =\n (\n key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | [],\n ):\n string => {\n\n const localPathNames = [...pathNames];\n logger.default('getPath', { key, pathNames: localPathNames });\n\n // console.log('getPath key: ' + JSON.stringify(key));\n\n const keys = generateKeyArray(key);\n\n // console.log('getPath keys: ' + JSON.stringify(keys));\n // console.log('getPath pathNames: ' + JSON.stringify(pathNames));\n\n // For contained items (ComKey), we need to process location keys first\n // to match the URL structure: /parents/{parentId}/children/{childId}\n if (keys.length > 1) {\n // Separate PriKeys and LocKeys\n const priKeys = keys.filter(k => isPriKey(k));\n const locKeys = keys.filter(k => !isPriKey(k));\n \n // Location keys come in child->parent order, but paths must be parent->child\n // So reverse the locKeys to get parent->child order for path building\n const reversedLocKeys = [...locKeys].reverse();\n \n // Reorder: reversed LocKeys first, then PriKeys\n const reorderedKeys = [...reversedLocKeys, ...priKeys];\n logger.default('Reordered keys for contained item', {\n original: keys,\n locKeys,\n reversedLocKeys,\n reordered: reorderedKeys,\n priKeys\n });\n \n let path: string = addPath('', reorderedKeys, localPathNames);\n\n // If there is only one collection left in the collections array, this means that\n // we received LocKeys and we need to add the last collection to the reference\n if (localPathNames.length === 1) {\n path = `${path}/${localPathNames[0]}`;\n }\n\n logger.default('getPath created', { key, path });\n return path;\n } else {\n // For primary items or single keys\n // If it's a LocKey array, we still need to reverse it for path building\n const priKeys = keys.filter(k => isPriKey(k));\n const locKeys = keys.filter(k => !isPriKey(k));\n \n // Reverse locKeys if present (child->parent to parent->child)\n const reversedLocKeys = locKeys.length > 0 ? [...locKeys].reverse() : [];\n const orderedKeys = [...reversedLocKeys, ...priKeys];\n \n let path: string = addPath('', orderedKeys, localPathNames);\n\n // If there is only one collection left in the collections array, this means that\n // we received LocKeys and we need to add the last collection to the reference\n if (localPathNames.length === 1) {\n path = `${path}/${localPathNames[0]}`;\n }\n\n logger.default('getPath created', { key, path });\n return path;\n }\n };\n\n const addPath = (\n base: string,\n keys: Array<PriKey<S> | LocKey<L1 | L2 | L3 | L4 | L5>>,\n localPathNames: string[],\n ): string => {\n logger.default('addPath', { base, keys, pathNames: localPathNames });\n if (keys.length < localPathNames.length - 1) {\n logger.error('addPath should never have keys with a length less than the length of pathNames - 1',\n { keys, localPathNames });\n throw new Error('addPath should never have keys with a length less than the length of pathNames - 1: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n } else if (keys.length > localPathNames.length) {\n logger.error('addPath should never have keys with a length greater than the length of pathNames',\n { keys, pathNames });\n throw new Error('addPath should never have keys with a length greater than the length of pathNames: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n }\n if (keys.length === 0) {\n // If you've recursively consumed all of the keys, return the base.\n logger.default('addPath returning base', { base });\n return base;\n } else {\n const currentKey = keys[0];\n const keyType = isPriKey(currentKey) ? currentKey.kt : currentKey.kt;\n \n // Find the best matching pathName for this key type\n const matchingPathNameIndex = localPathNames.findIndex(pathName => {\n const singularPathName = pathName.endsWith('s') ? pathName.slice(0, -1) : pathName;\n const pluralKeyType = keyType + 's';\n \n // Try various matching strategies\n return pathName === pluralKeyType || // photos === photo+s\n pathName === keyType + 'es' || // matches === match+es\n singularPathName === keyType || // photo === photo\n pathName.toLowerCase() === keyType.toLowerCase() || // case insensitive\n pathName.toLowerCase() === pluralKeyType.toLowerCase(); // case insensitive plural\n });\n \n if (matchingPathNameIndex !== -1) {\n // Found a matching pathName\n const pathName = localPathNames.splice(matchingPathNameIndex, 1)[0];\n const key = keys.shift()!;\n const id = isPriKey(key) ? (key as PriKey<S>).pk : (key as LocKey<L1 | L2 | L3 | L4 | L5>).lk;\n const nextBase = `${base}/${pathName}/${id}`;\n logger.default('Adding Path (matched)', {\n pathName,\n keyType,\n isPriKey: isPriKey(key),\n key,\n nextBase\n });\n return addPath(nextBase, keys, localPathNames);\n } else {\n // No match found, use first available pathName\n const pathName = localPathNames.shift()!;\n const key = keys.shift()!;\n const id = isPriKey(key) ? (key as PriKey<S>).pk : (key as LocKey<L1 | L2 | L3 | L4 | L5>).lk;\n const nextBase = `${base}/${pathName}/${id}`;\n logger.default('Adding Path (no match, using first)', {\n pathName,\n keyType,\n isPriKey: isPriKey(key),\n key,\n nextBase\n });\n return addPath(nextBase, keys, localPathNames);\n }\n }\n\n }\n\n const validatePK = (\n item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]):\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {\n return coreValidatePK<S, L1, L2, L3, L4, L5>(item, pkType);\n }\n\n return {\n verifyLocations,\n processOne,\n convertDoc,\n processArray,\n getPath,\n validatePK,\n }\n}\n", "/* eslint-disable indent */\nimport { Item } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nimport { getOperations } from \"./ops\";\nimport { createUtilities } from \"./Utilities\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"./logger\";\n\nconst logger = LibLogger.get('AItemAPI');\n\nexport type PathNamesArray<\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> =\n ([L5] extends [never] ?\n ([L4] extends [never] ?\n ([L3] extends [never] ?\n ([L2] extends [never] ?\n ([L1] extends [never] ?\n [string] :\n [string, string]) :\n [string, string, string]) :\n [string, string, string, string]) :\n [string, string, string, string, string]) :\n [string, string, string, string, string, string]);\n\nexport const finderToParams = (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>\n): Record<string, string> => {\n return {\n finder,\n finderParams: JSON.stringify(finderParams),\n };\n};\n\nexport const createAItemAPI = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n api: HttpApi,\n pkType: S,\n pathNames: PathNamesArray<L1, L2, L3, L4, L5>,\n options?: ClientApiOptions,\n): ClientApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createAItemAPI', { pkType, pathNames, options });\n\n let mergedOptions: ClientApiOptions;\n\n const defaultOptions: ClientApiOptions = {\n readAuthenticated: true,\n allAuthenticated: true,\n writeAuthenticated: true,\n getOptions: {},\n postOptions: {},\n putOptions: {},\n deleteOptions: {},\n };\n\n if (options) {\n mergedOptions = Object.assign({}, defaultOptions, options);\n } else {\n mergedOptions = defaultOptions;\n }\n\n const utilities = createUtilities<V, S, L1, L2, L3, L4, L5>(pkType, pathNames);\n const operations = getOperations<V, S, L1, L2, L3, L4, L5>(api, mergedOptions, utilities);\n\n return {\n action: operations.action,\n all: operations.all,\n allAction: operations.allAction,\n allFacet: operations.allFacet,\n create: operations.create,\n facet: operations.facet,\n find: operations.find,\n findOne: operations.findOne,\n get: operations.get,\n one: operations.one,\n remove: operations.remove,\n update: operations.update,\n upsert: operations.upsert,\n }\n}", "\nimport {\n Item,\n} from \"@fjell/core\";\nimport {\n HttpApi\n} from \"@fjell/http-api\";\nimport { createAItemAPI, PathNamesArray } from \"./AItemAPI\";\n\nimport LibLogger from \"./logger\";\nimport { ClientApi } from \"./ClientApi\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\n\nconst logger = LibLogger.get('CItemAPI');\n\n/**\n * CItemApi extends ClientApi for contained items.\n * No additional methods needed - pure Operations interface.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface CItemApi<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n> extends ClientApi<V, S, L1, L2, L3, L4, L5> {\n // Inherits all methods from ClientApi (which extends core Operations)\n}\n\nexport const createCItemApi = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions): CItemApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createCItemApi', { api, type, pathNames, options });\n\n const aItemAPI = createAItemAPI(api, type, pathNames, options);\n\n return {\n action: aItemAPI.action,\n all: aItemAPI.all,\n allAction: aItemAPI.allAction,\n allFacet: aItemAPI.allFacet,\n one: aItemAPI.one,\n get: aItemAPI.get,\n create: aItemAPI.create,\n remove: aItemAPI.remove,\n update: aItemAPI.update,\n upsert: aItemAPI.upsert,\n facet: aItemAPI.facet,\n find: aItemAPI.find,\n findOne: aItemAPI.findOne,\n } as unknown as CItemApi<V, S, L1, L2, L3, L4, L5>;\n}\n", "import { AllOptions, ComKey, Item, ItemQuery, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\nimport { createAItemAPI } from \"./AItemAPI\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"./logger\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nconst logger = LibLogger.get('PItemAPI');\n\n// PItemApi now directly extends ClientApi without re-declaring methods\n// This ensures compatibility with core Operations interface\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PItemApi<\n V extends Item<S>,\n S extends string\n> extends ClientApi<V, S> {\n // Inherits all methods from ClientApi\n}\n\nexport const createPItemApi = <V extends Item<S>, S extends string>(\n api: HttpApi,\n type: S,\n pathName: string,\n options?: ClientApiOptions\n): PItemApi<V, S> => {\n\n logger.default('createPItemApi', { type, pathName, options });\n\n const aItemAPI = createAItemAPI<V, S>(api, type, [pathName], options);\n\n // Simplified wrapper functions that adapt to primary-only API (no locations)\n const action = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n action: string,\n params?: any,\n ) => await aItemAPI.action(ik, action, params);\n\n const all = async (query?: ItemQuery, locations?: [], allOptions?: AllOptions) =>\n await aItemAPI.all(query || {}, locations || [], allOptions);\n\n const allAction = async (action: string, params?: any) =>\n await aItemAPI.allAction(action, params, []);\n\n const allFacet = async (facet: string, params?: any) =>\n await aItemAPI.allFacet(facet, params);\n\n const one = async (query?: ItemQuery) =>\n await aItemAPI.one(query || {}, []);\n\n const get = async (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) =>\n await aItemAPI.get(ik);\n\n const create = async (item: Partial<Item<S>>, options?: any) =>\n await aItemAPI.create(item, options);\n\n const remove = async (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) =>\n await aItemAPI.remove(ik);\n\n const update = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: Partial<Item<S>>,\n ) => await aItemAPI.update(ik, item);\n\n const upsert = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: Partial<Item<S>>,\n locations?: any\n ) => await aItemAPI.upsert(ik, item, locations);\n\n const facet = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n facet: string,\n params?: any,\n ) => await aItemAPI.facet(ik, facet, params);\n\n const find = async (finder: string, finderParams?: any) =>\n await aItemAPI.find(finder, finderParams);\n\n const findOne = async (finder: string, finderParams?: any) =>\n await aItemAPI.findOne(finder, finderParams);\n\n return {\n action,\n all,\n allAction,\n allFacet,\n one,\n get,\n create,\n remove,\n update,\n upsert,\n facet,\n find,\n findOne,\n } as PItemApi<V, S>;\n\n};\n", "\nimport LibLogger from \"./logger\";\nimport { Item } from \"@fjell/core\";\nimport { Instance as BaseInstance, createInstance as createBaseInstance, Registry } from \"@fjell/registry\";\nimport { ClientApi } from \"./ClientApi\";\nimport { Coordinate } from \"@fjell/core\";\n\nconst logger = LibLogger.get(\"Instance\");\n\n/**\n * The Client API Instance interface represents a client API model instance that extends the base Instance\n * from @fjell/registry and adds client API operations for interacting with remote data.\n *\n * The interface extends the base Instance (which provides coordinate and registry) with:\n * - clientApi: Provides methods for interacting with remote data through HTTP APIs (get, create, update, etc.)\n *\n * @template V - The type of the data model item, extending Item\n * @template S - The string literal type representing the model's key type\n * @template L1-L5 - Optional string literal types for location hierarchy levels\n */\nexport interface Instance<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends BaseInstance<S, L1, L2, L3, L4, L5> {\n /** The client API object that provides methods for interacting with remote data */\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>;\n}\n\nexport const createInstance = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n registry: Registry,\n coordinate: Coordinate<S, L1, L2, L3, L4, L5>,\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>,\n ): Instance<V, S, L1, L2, L3, L4, L5> => {\n logger.debug(\"createInstance\", { coordinate, clientApi, registry });\n const baseInstance = createBaseInstance(registry, coordinate);\n return { ...baseInstance, clientApi };\n}\n", "import { Item } from \"@fjell/core\";\nimport { ClientApi } from \"./ClientApi\";\nimport { InstanceFactory as BaseInstanceFactory, Registry, RegistryHub } from \"@fjell/registry\";\nimport { createInstance, Instance } from \"./Instance\";\nimport { Coordinate } from \"@fjell/core\";\nimport LibLogger from \"./logger\";\n\nconst logger = LibLogger.get(\"InstanceFactory\");\n\nexport type InstanceFactory<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> = (\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;\n\n/**\n * Factory function for creating client-api instances\n */\nexport const createInstanceFactory = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n ): BaseInstanceFactory<S, L1, L2, L3, L4, L5> => {\n return (coordinate: Coordinate<S, L1, L2, L3, L4, L5>, context: { registry: Registry, registryHub?: RegistryHub }) => {\n logger.debug(\"Creating client-api instance\", { coordinate, registry: context.registry, clientApi });\n\n return createInstance(context.registry, coordinate, clientApi) as Instance<V, S, L1, L2, L3, L4, L5>;\n };\n};\n", "import LibLogger from './logger';\nimport {\n Registry as BaseRegistry,\n createRegistry as createBaseRegistry,\n RegistryFactory,\n RegistryHub\n} from '@fjell/registry';\n\nconst logger = LibLogger.get(\"Registry\");\n\n/**\n * Extended Registry interface for client-api-specific functionality\n */\nexport interface Registry extends BaseRegistry {\n type: 'client-api';\n}\n\n/**\n * Factory function for creating client-api registries\n */\nexport const createRegistryFactory = (): RegistryFactory => {\n return (type: string, registryHub?: RegistryHub): BaseRegistry => {\n if (type !== 'client-api') {\n throw new Error(`Client API registry factory can only create 'client-api' type registries, got: ${type}`);\n }\n\n logger.debug(\"Creating client-api registry\", { type, registryHub });\n\n const baseRegistry = createBaseRegistry(type, registryHub);\n\n // Cast to Registry for type safety\n return baseRegistry as Registry;\n };\n};\n\n/**\n * Creates a new client-api registry instance\n */\nexport const createRegistry = (registryHub?: RegistryHub): Registry => {\n const baseRegistry = createBaseRegistry('client-api', registryHub);\n\n return {\n ...baseRegistry,\n } as Registry;\n};\n", "/**\n * Base class for all Client API errors\n */\nexport abstract class ClientApiError extends Error {\n abstract readonly code: string;\n abstract readonly isRetryable: boolean;\n readonly timestamp: Date;\n readonly context?: Record<string, any>;\n\n constructor(message: string, context?: Record<string, any>) {\n super(message);\n this.name = this.constructor.name;\n this.timestamp = new Date();\n this.context = context;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n isRetryable: this.isRetryable,\n timestamp: this.timestamp,\n context: this.context,\n stack: this.stack\n };\n }\n}\n\n/**\n * Network-related errors (connection issues, timeouts)\n */\nexport class NetworkError extends ClientApiError {\n readonly code = 'NETWORK_ERROR';\n readonly isRetryable = true;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Network error: ${message}`, context);\n }\n}\n\n/**\n * HTTP timeout errors\n */\nexport class TimeoutError extends ClientApiError {\n readonly code = 'TIMEOUT_ERROR';\n readonly isRetryable = true;\n\n constructor(timeout: number, context?: Record<string, any>) {\n super(`Request timed out after ${timeout}ms`, context);\n }\n}\n\n/**\n * Authentication errors (401 Unauthorized)\n */\nexport class AuthenticationError extends ClientApiError {\n readonly code = 'AUTHENTICATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message?: string, context?: Record<string, any>) {\n super(message || 'Authentication failed - invalid or expired credentials', context);\n }\n}\n\n/**\n * Authorization errors (403 Forbidden)\n */\nexport class AuthorizationError extends ClientApiError {\n readonly code = 'AUTHORIZATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message?: string, context?: Record<string, any>) {\n super(message || 'Access forbidden - insufficient permissions', context);\n }\n}\n\n/**\n * Resource not found errors (404 Not Found)\n */\nexport class NotFoundError extends ClientApiError {\n readonly code = 'NOT_FOUND_ERROR';\n readonly isRetryable = false;\n\n constructor(resource: string, identifier?: string, context?: Record<string, any>) {\n const message = identifier\n ? `${resource} with identifier '${identifier}' not found`\n : `${resource} not found`;\n super(message, context);\n }\n}\n\n/**\n * Request validation errors (400 Bad Request)\n */\nexport class ValidationError extends ClientApiError {\n readonly code = 'VALIDATION_ERROR';\n readonly isRetryable = false;\n readonly validationErrors?: Array<{ field: string; message: string }>;\n\n constructor(message: string, validationErrors?: Array<{ field: string; message: string }>, context?: Record<string, any>) {\n super(`Validation error: ${message}`, context);\n this.validationErrors = validationErrors;\n }\n}\n\n/**\n * Conflict errors (409 Conflict)\n */\nexport class ConflictError extends ClientApiError {\n readonly code = 'CONFLICT_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Conflict: ${message}`, context);\n }\n}\n\n/**\n * Rate limiting errors (429 Too Many Requests)\n */\nexport class RateLimitError extends ClientApiError {\n readonly code = 'RATE_LIMIT_ERROR';\n readonly isRetryable = true;\n readonly retryAfter?: number;\n\n constructor(retryAfter?: number, context?: Record<string, any>) {\n const message = retryAfter\n ? `Rate limit exceeded - retry after ${retryAfter} seconds`\n : 'Rate limit exceeded';\n super(message, context);\n this.retryAfter = retryAfter;\n }\n}\n\n/**\n * Server errors (5xx status codes)\n */\nexport class ServerError extends ClientApiError {\n readonly code = 'SERVER_ERROR';\n readonly isRetryable = true;\n readonly statusCode: number;\n\n constructor(statusCode: number, message?: string, context?: Record<string, any>) {\n super(message || `Server error (${statusCode})`, context);\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Request payload too large errors (413)\n */\nexport class PayloadTooLargeError extends ClientApiError {\n readonly code = 'PAYLOAD_TOO_LARGE_ERROR';\n readonly isRetryable = false;\n\n constructor(maxSize?: string, context?: Record<string, any>) {\n const message = maxSize\n ? `Request payload too large - maximum size is ${maxSize}`\n : 'Request payload too large';\n super(message, context);\n }\n}\n\n/**\n * Generic HTTP errors for unhandled status codes\n */\nexport class HttpError extends ClientApiError {\n readonly code = 'HTTP_ERROR';\n readonly isRetryable: boolean;\n readonly statusCode: number;\n readonly statusText: string;\n\n constructor(statusCode: number, statusText: string, message?: string, context?: Record<string, any>) {\n super(message || `HTTP error ${statusCode}: ${statusText}`, context);\n this.statusCode = statusCode;\n this.statusText = statusText;\n\n // 5xx errors are generally retryable, 4xx are not\n this.isRetryable = statusCode >= 500;\n }\n}\n\n/**\n * Configuration errors\n */\nexport class ConfigurationError extends ClientApiError {\n readonly code = 'CONFIGURATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Configuration error: ${message}`, context);\n }\n}\n\n/**\n * Parse/serialization errors\n */\nexport class ParseError extends ClientApiError {\n readonly code = 'PARSE_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Parse error: ${message}`, context);\n }\n}\n\n/**\n * Create appropriate error from HTTP response\n */\nexport function createHttpError(\n statusCode: number,\n statusText: string,\n responseBody?: any,\n context?: Record<string, any>\n): ClientApiError {\n const errorContext = { statusCode, statusText, responseBody, ...context };\n\n switch (statusCode) {\n case 400:\n if (responseBody?.validationErrors) {\n return new ValidationError(\n responseBody.message || 'Request validation failed',\n responseBody.validationErrors,\n errorContext\n );\n }\n return new ValidationError(responseBody?.message || statusText, [], errorContext);\n\n case 401:\n return new AuthenticationError(responseBody?.message, errorContext);\n\n case 403:\n return new AuthorizationError(responseBody?.message, errorContext);\n\n case 404:\n return new NotFoundError(\n responseBody?.resource || 'Resource',\n responseBody?.identifier,\n errorContext\n );\n\n case 409:\n return new ConflictError(responseBody?.message || statusText, errorContext);\n\n case 413:\n return new PayloadTooLargeError(responseBody?.maxSize, errorContext);\n\n case 429: {\n let retryAfter: number | undefined;\n if (responseBody?.retryAfter) {\n retryAfter = responseBody.retryAfter;\n } else if (context?.headers?.['retry-after']) {\n retryAfter = parseInt(context.headers['retry-after']);\n }\n return new RateLimitError(retryAfter, errorContext);\n }\n\n default:\n if (statusCode >= 500) {\n return new ServerError(statusCode, responseBody?.message || statusText, errorContext);\n }\n\n return new HttpError(statusCode, statusText, responseBody?.message, errorContext);\n }\n}\n\n/**\n * Create appropriate error from network/connection issues\n */\nexport function createNetworkError(error: any, context?: Record<string, any>): ClientApiError {\n const errorContext = { originalError: error, ...context };\n\n if (error.code === 'ECONNABORTED' || error.message?.includes('timeout')) {\n return new TimeoutError(error.timeout || 5000, errorContext);\n }\n\n if (error.code === 'ECONNREFUSED' ||\n error.code === 'ENOTFOUND' ||\n error.code === 'ENETUNREACH' ||\n error.message?.includes('network')) {\n return new NetworkError(error.message || 'Network connection failed', errorContext);\n }\n\n // For unknown errors, treat as network issues that might be retryable\n return new NetworkError(error.message || 'Unknown network error', errorContext);\n}\n\n/**\n * Type guard to check if error is retryable\n */\nexport function isRetryableError(error: any): boolean {\n return error instanceof ClientApiError && error.isRetryable;\n}\n\n/**\n * Type guard to check if error is a Client API error\n */\nexport function isClientApiError(error: any): error is ClientApiError {\n return error instanceof ClientApiError;\n}\n", "export type { CItemApi } from \"./CItemAPI\";\nexport type { PItemApi } from \"./PItemAPI\";\nexport type { ClientApi } from \"./ClientApi\";\nexport type { ClientApiOptions } from \"./ClientApiOptions\";\n\nexport { createCItemApi } from \"./CItemAPI\";\nexport { createPItemApi } from \"./PItemAPI\";\n\n// Registry components\nexport * from './Instance';\nexport * from './InstanceFactory';\nexport * from './Registry';\n\n// Error handling\nexport * from './errors/index';\nexport * from './ops/errorHandling';\n\n// Re-export FjellHttpError from http-api for convenience\nexport { FjellHttpError, isFjellHttpError, extractErrorInfo, type ErrorInfo } from '@fjell/http-api';\n\n// HTTP wrapper\nexport * from './http/HttpWrapper';\n", "import { HttpApi } from '@fjell/http-api';\nimport {\n ClientApiError,\n createHttpError,\n createNetworkError,\n RateLimitError\n} from '../errors/index';\n\n// Simple logger interface for now\nconst logger = {\n debug: (message: string, context?: any) => console.debug(message, context),\n info: (message: string, context?: any) => console.info(message, context),\n warning: (message: string, context?: any) => console.warn(message, context),\n error: (message: string, context?: any) => console.error(message, context)\n};\n\n/**\n * Configuration for retry behavior\n */\nexport interface RetryConfig {\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n /** Initial delay between retries in milliseconds (default: 1000) */\n initialDelayMs?: number;\n /** Maximum delay between retries in milliseconds (default: 30000) */\n maxDelayMs?: number;\n /** Backoff multiplier for exponential backoff (default: 2) */\n backoffMultiplier?: number;\n /** Whether to add jitter to retry delays (default: true) */\n enableJitter?: boolean;\n /** Custom function to determine if an error should be retried */\n shouldRetry?: (error: ClientApiError, attemptNumber: number) => boolean;\n /** Called before each retry attempt */\n onRetry?: (error: ClientApiError, attemptNumber: number, delay: number) => void;\n}\n\n/**\n * Default retry configuration\n */\nconst DEFAULT_RETRY_CONFIG: Required<RetryConfig> = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n enableJitter: true,\n shouldRetry: (error: ClientApiError, attemptNumber: number) => {\n // Don't retry after max attempts\n if (attemptNumber >= 3) return false;\n\n // Always retry retryable errors\n if (error.isRetryable) return true;\n\n // Don't retry non-retryable errors\n return false;\n },\n onRetry: (error: ClientApiError, attemptNumber: number, delay: number) => {\n logger.warning(`Retrying HTTP request (attempt ${attemptNumber + 1}) after ${delay}ms`, {\n errorCode: error.code,\n errorMessage: error.message,\n delay,\n attemptNumber\n });\n }\n};\n\n/**\n * Sleep utility for retry delays\n */\nconst sleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms));\n\n/**\n * Calculate delay for exponential backoff with optional jitter\n */\nfunction calculateDelay(\n attemptNumber: number,\n config: Required<RetryConfig>\n): number {\n const exponentialDelay = config.initialDelayMs * Math.pow(config.backoffMultiplier, attemptNumber);\n const cappedDelay = Math.min(exponentialDelay, config.maxDelayMs);\n\n if (!config.enableJitter) {\n return cappedDelay;\n }\n\n // Add jitter: random value between 50% and 100% of calculated delay\n const jitter = 0.5 + (Math.random() * 0.5);\n return Math.floor(cappedDelay * jitter);\n}\n\n/**\n * Enhanced HTTP wrapper with retry logic and comprehensive error handling\n */\nexport class HttpWrapper {\n private readonly api: HttpApi;\n private readonly retryConfig: Required<RetryConfig>;\n\n constructor(api: HttpApi, retryConfig: RetryConfig = {}) {\n this.api = api;\n this.retryConfig = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };\n }\n\n /**\n * Execute HTTP operation with retry logic and error handling\n */\n async executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string,\n context?: Record<string, any>\n ): Promise<T> {\n let lastError: ClientApiError | null = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= this.retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Executing ${operationName}`, {\n attempt: attempt + 1,\n maxRetries: this.retryConfig.maxRetries + 1,\n ...context\n });\n\n const result = await operation();\n\n if (attempt > 0) {\n logger.info(`${operationName} succeeded after ${attempt} retries`, {\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime,\n ...context\n });\n }\n\n return result;\n } catch (error) {\n lastError = this.convertToClientApiError(error, operationName, context);\n\n // Don't retry on the last attempt\n if (attempt === this.retryConfig.maxRetries) {\n break;\n }\n\n // Check if we should retry this error\n if (!this.retryConfig.shouldRetry(lastError, attempt)) {\n logger.debug(`Not retrying ${operationName} due to non-retryable error`, {\n errorCode: lastError.code,\n errorMessage: lastError.message,\n attempt: attempt + 1,\n ...context\n });\n break;\n }\n\n // Handle rate limiting with custom delay\n let delay = calculateDelay(attempt, this.retryConfig);\n if (lastError instanceof RateLimitError && lastError.retryAfter) {\n delay = Math.max(delay, lastError.retryAfter * 1000);\n }\n\n // Call retry callback\n this.retryConfig.onRetry(lastError, attempt, delay);\n\n // Wait before retrying\n await sleep(delay);\n }\n }\n\n // Log final failure\n logger.error(`${operationName} failed after ${this.retryConfig.maxRetries + 1} attempts`, {\n errorCode: lastError?.code,\n errorMessage: lastError?.message,\n duration: Date.now() - startTime,\n ...context\n });\n\n throw lastError;\n }\n\n /**\n * Convert any error to a ClientApiError\n */\n private convertToClientApiError(\n error: any,\n operationName: string,\n context?: Record<string, any>\n ): ClientApiError {\n const errorContext = { operation: operationName, ...context };\n\n // If it's already a ClientApiError, return as-is\n if (error instanceof ClientApiError) {\n return error;\n }\n\n // Handle HTTP response errors\n if (error.response) {\n const { status, statusText, data, headers } = error.response;\n return createHttpError(status, statusText, data, {\n ...errorContext,\n headers,\n url: error.config?.url\n });\n }\n\n // Handle request errors (network issues, timeouts, etc.)\n if (error.request) {\n return createNetworkError(error, {\n ...errorContext,\n url: error.config?.url,\n method: error.config?.method\n });\n }\n\n // Handle configuration or other errors\n return createNetworkError(error, errorContext);\n }\n\n /**\n * Wrapper for HTTP GET operations\n */\n async get<T>(\n url: string,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpGet(url, options),\n 'GET',\n { url, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP POST operations\n */\n async post<T>(\n url: string,\n data?: any,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpPost(url, data, options),\n 'POST',\n { url, hasData: !!data, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP PUT operations\n */\n async put<T>(\n url: string,\n data?: any,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpPut(url, data, options),\n 'PUT',\n { url, hasData: !!data, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP DELETE operations\n */\n async delete<T>(\n url: string,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpDelete(url, options),\n 'DELETE',\n { url, ...context }\n );\n }\n\n /**\n * Update retry configuration\n */\n updateRetryConfig(newConfig: Partial<RetryConfig>): void {\n Object.assign(this.retryConfig, newConfig);\n }\n\n /**\n * Get current retry configuration\n */\n getRetryConfig(): Required<RetryConfig> {\n return { ...this.retryConfig };\n }\n}\n"],
5
- "mappings": ";AAAA;AAAA,EAOE;AAAA,OACK;;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,KAAK,IAAI,SAAS,KAAK,MAAM,OAAO;AAAA,MAC1C;AAAA,MACA,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IACJ,KACA,MACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,QAAQ,KAAK,MAAM,OAAO;AAAA,MACzC;AAAA,MACA,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OACJ,KACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,WAAW,KAAK,OAAO;AAAA,MACtC;AAAA,MACA,EAAE,KAAK,GAAG,QAAQ;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,WAAuC;AACvD,WAAO,OAAO,KAAK,aAAa,SAAS;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAwC;AACtC,WAAO,EAAE,GAAG,KAAK,YAAY;AAAA,EAC/B;AACF;",
6
- "names": ["logger", "action", "logger", "queryToParams", "logger", "queryToParams", "logger", "logger", "logger", "logger", "logger", "totalDuration", "logger", "logger", "logger", "logger", "facet", "logger", "logger", "logger", "logger", "logger", "action", "facet", "options", "logger", "logger", "logger", "isFjellHttpError", "logger"]
4
+ "sourcesContent": ["import {\n AllMethod,\n AllOperationResult,\n AllOptions,\n Item,\n ItemQuery,\n LocKeyArray,\n queryToParams,\n} from \"@fjell/core\";\nimport { HttpApi, QueryParams } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'all');\n\nexport const getAllOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): AllMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const all = async (\n query: ItemQuery = {} as ItemQuery,\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = [],\n allOptions?: AllOptions\n ): Promise<AllOperationResult<V>> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // Build query params from ItemQuery\n const params: QueryParams = queryToParams(query);\n\n // Override with AllOptions if provided (takes precedence)\n if (allOptions && 'limit' in allOptions && allOptions.limit != null) {\n params.limit = String(allOptions.limit);\n }\n if (allOptions && 'offset' in allOptions && allOptions.offset != null) {\n params.offset = String(allOptions.offset);\n }\n\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params });\n\n logger.default('all', { query, locations, allOptions, requestOptions });\n logger.debug('QUERY_CACHE: client-api.all() - Making API request', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n allOptions: JSON.stringify(allOptions),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n // Server returns AllOperationResult<V> with items and metadata\n const result = await api.httpGet<AllOperationResult<V>>(\n utilities.getPath(loc),\n requestOptions,\n );\n\n // Handle case where server returns {} or result.items is undefined\n // Extract items array from result, defaulting to empty array if missing\n let itemsArray: V[] = [];\n if (result) {\n if (result.items && Array.isArray(result.items)) {\n itemsArray = result.items;\n } else if (Array.isArray(result)) {\n itemsArray = result;\n } else {\n // Log unexpected response format\n logger.warning('Unexpected response format from server', {\n result,\n resultType: typeof result,\n hasItems: 'items' in result,\n resultKeys: result && typeof result === 'object' ? Object.keys(result) : []\n });\n itemsArray = [];\n }\n }\n\n // Ensure itemsArray is always a valid array before processing\n if (!Array.isArray(itemsArray)) {\n logger.error('itemsArray is not an array, defaulting to empty array', { itemsArray });\n itemsArray = [];\n }\n\n // Process items through utilities (date conversion, validation, etc.)\n const processedItems = await utilities.processArray(Promise.resolve(itemsArray));\n\n logger.debug('QUERY_CACHE: client-api.all() - API response received', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n itemCount: processedItems.length,\n total: result?.metadata?.total,\n hasMore: result?.metadata?.hasMore,\n itemKeys: processedItems.map(item => JSON.stringify(item.key))\n });\n\n // Return AllOperationResult with processed items\n return {\n items: processedItems,\n metadata: result?.metadata || { total: 0, returned: 0, offset: 0, hasMore: false }\n };\n }\n\n return all;\n}\n\n", "import Logging from '@fjell/logging';\n\nconst LibLogger = Logging.getLogger('@fjell/client-api');\n\nexport default LibLogger;\n", "import { ActionOperationMethod, ComKey, Item, LocKeyArray, OperationParams, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'action');\n\nexport const getActionOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ): ActionOperationMethod<V, S, L1, L2, L3, L4, L5> => {\n const action = async (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n action: string,\n params?: OperationParams,\n ): Promise<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]> => {\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('action', { ik, action, params, requestOptions });\n\n const response = await api.httpPost<[V, Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>(\n `${utilities.getPath(ik)}/${action}`,\n params || {},\n requestOptions,\n );\n\n const [item, affectedItems] = response;\n return [\n await utilities.processOne(Promise.resolve(item)),\n affectedItems\n ];\n };\n return action;\n}\n", " \nimport { AllActionOperationMethod, ComKey, Item, LocKeyArray, OperationParams, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'allAction');\n\nexport const getAllActionOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ): AllActionOperationMethod<V, S, L1, L2, L3, L4, L5> => {\n const allAction = async (\n action: string,\n params?: OperationParams,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | []\n ): Promise<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]> => {\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations || [];\n logger.default('allAction', { action, params, locations: loc, requestOptions });\n utilities.verifyLocations(loc);\n\n const response = await api.httpPost<[V[], Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>>]>(\n `${utilities.getPath(loc)}/${action}`,\n params || {},\n requestOptions,\n );\n\n // Handle edge cases where response might not be an array\n let items: V[] = [];\n let affectedItems: Array<PriKey<any> | ComKey<any, any, any, any, any, any> | LocKeyArray<any, any, any, any, any>> = [];\n\n if (Array.isArray(response)) {\n // Check if this is a properly formatted tuple response [items, affectedItems]\n if (response.length === 2 && Array.isArray(response[0])) {\n [items, affectedItems] = response;\n } else {\n // Handle other array responses - return as-is\n return response as any;\n }\n } else if (response && typeof response === 'object' && Object.keys(response).length === 0) {\n // Handle empty object response {}\n items = [];\n affectedItems = [];\n } else if (typeof response === 'string' && response === '{}') {\n // Handle string response \"{}\"\n items = [];\n affectedItems = [];\n }\n\n const processedItems = await utilities.processArray(Promise.resolve(items));\n if (Array.isArray(processedItems)) {\n processedItems.forEach(item => utilities.validatePK(item));\n }\n return [\n processedItems,\n affectedItems\n ];\n };\n return allAction;\n}\n", "import {\n AllOperationResult,\n Item,\n ItemQuery,\n LocKeyArray,\n OneMethod,\n QueryParams,\n queryToParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'one');\n\nexport const getOneOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): OneMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const one = async (\n query: ItemQuery = {} as ItemQuery,\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V | null> => {\n utilities.verifyLocations(locations);\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // Add limit: 1 to optimize the query\n const params: QueryParams = queryToParams(query);\n params.limit = '1';\n \n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.readAuthenticated, params });\n logger.default('one', { query, locations, requestOptions });\n logger.debug('QUERY_CACHE: client-api.one() - Making API request', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.readAuthenticated\n });\n\n // Server returns AllOperationResult<V> with items and metadata\n const result = await api.httpGet<AllOperationResult<V>>(\n utilities.getPath(loc),\n requestOptions,\n );\n\n // Process items through utilities (date conversion, validation, etc.)\n const items = await utilities.processArray(Promise.resolve(result.items));\n\n let item: V | null = null;\n if (items.length > 0) {\n item = items[0];\n logger.debug('QUERY_CACHE: client-api.one() - API response received', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations),\n itemKey: JSON.stringify(item.key)\n });\n } else {\n logger.debug('QUERY_CACHE: client-api.one() - API returned no items', {\n query: JSON.stringify(query),\n locations: JSON.stringify(locations)\n });\n }\n\n return item;\n }\n\n return one;\n}\n", "/**\n * Shared error handling utilities for all HTTP operations\n */\n\nimport { isFjellHttpError } from '@fjell/http-api';\n\n/**\n * Determines if an error should be retried based on error type and status code\n */\nexport function shouldRetryError(error: any): boolean {\n // Check FjellHttpError retryable flag first\n if (isFjellHttpError(error)) {\n return error.isRetryable();\n }\n\n // Retry on network errors and timeouts\n if (error.code === 'ECONNREFUSED' ||\n error.code === 'ENOTFOUND' ||\n error.code === 'ENETUNREACH' ||\n error.message?.includes('timeout') ||\n error.message?.includes('network')) {\n return true;\n }\n\n // Retry on HTTP 5xx errors and 429 (rate limiting)\n if (error.status >= 500 || error.status === 429) {\n return true;\n }\n\n // Don't retry on 4xx client errors (except 429)\n if (error.status >= 400 && error.status < 500 && error.status !== 429) {\n return false;\n }\n\n // Default to retrying unknown errors\n return true;\n}\n\n/**\n * Calculates retry delay with exponential backoff and jitter\n */\nexport function calculateRetryDelay(attempt: number, config: any): number {\n const exponentialDelay = (config.initialDelayMs || 1000) * Math.pow(config.backoffMultiplier || 2, attempt);\n const cappedDelay = Math.min(exponentialDelay, config.maxDelayMs || 30000);\n\n // Add jitter: random value between 50% and 100% of calculated delay\n const jitter = 0.5 + (Math.random() * 0.5);\n return Math.floor(cappedDelay * jitter);\n}\n\n/**\n * Enhances error with additional context information\n * Preserves FjellHttpError without modification\n */\nexport function enhanceError(error: any, context: any): any {\n if (!error) return new Error('Unknown error occurred');\n\n // Don't modify FjellHttpError - it already has full context\n if (isFjellHttpError(error)) {\n return error;\n }\n\n // If it's already enhanced, return as-is\n if (error.context) return error;\n\n // Add context to the error\n const enhancedError = new Error(error.message || 'HTTP operation failed');\n Object.assign(enhancedError, {\n code: error.code || error.status || 'UNKNOWN_ERROR',\n status: error.status,\n context,\n originalError: error\n });\n\n return enhancedError;\n}\n\n/**\n * Gets default retry configuration merged with provided options\n */\nexport function getRetryConfig(apiOptions: any): any {\n return {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n}\n\n/**\n * Handles custom error handler execution with error protection\n */\nexport function executeErrorHandler(\n errorHandler: ((error: any, context?: Record<string, any>) => void) | undefined,\n error: any,\n context: any,\n logger: any\n): void {\n if (!errorHandler) return;\n\n try {\n errorHandler(error, context);\n } catch (handlerError: any) {\n logger.error('Custom error handler failed', {\n originalError: error.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n}\n\n/**\n * Common retry loop logic for HTTP operations\n */\nexport async function executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string,\n operationContext: Record<string, any>,\n apiOptions: any,\n logger: any,\n specialErrorHandling?: (error: any) => T | null | undefined\n): Promise<T> {\n const retryConfig = getRetryConfig(apiOptions);\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Executing ${operationName} (attempt ${attempt + 1})`, operationContext);\n\n const result = await operation();\n\n if (attempt > 0) {\n logger.info(`${operationName} operation succeeded after ${attempt} retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n\n // Handle special error cases (like 404 returning null)\n if (specialErrorHandling) {\n const specialResult = specialErrorHandling(error);\n if (specialResult !== void 0) {\n return specialResult as T;\n }\n }\n\n // Don't retry on the last attempt\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n // Check if we should retry this error\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug(`Not retrying ${operationName} operation due to non-retryable error`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n attempt: attempt + 1\n });\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`Retrying ${operationName} operation (attempt ${attempt + 2}) after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n delay,\n attemptNumber: attempt + 1\n });\n\n // Wait before retrying\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n // Handle final error\n const finalError = enhanceError(lastError, operationContext);\n\n // Execute custom error handler if provided\n executeErrorHandler(apiOptions.errorHandler, finalError, operationContext, logger);\n\n logger.error(`${operationName} operation failed after ${retryConfig.maxRetries + 1} attempts`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n duration: Date.now() - startTime,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n}\n", "import {\n CreateMethod,\n CreateOptions,\n Item,\n LocKeyArray\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\nimport { calculateRetryDelay, enhanceError, shouldRetryError } from \"./errorHandling\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'create');\n\nexport const getCreateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): CreateMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const create = async (\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n options?: CreateOptions<S, L1, L2, L3, L4, L5>\n ): Promise<V> => {\n // Extract locations or key from options for backward compatibility\n const locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = options?.locations || [];\n const requestOptions = Object.assign({}, apiOptions.postOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('create', { item, options, locations, requestOptions });\n utilities.verifyLocations(locations);\n \n // If a key was provided in options, include it in the item\n let itemToCreate = item;\n if (options?.key) {\n itemToCreate = { ...item, ...options.key };\n }\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n const operationContext = {\n operation: 'create',\n path: utilities.getPath(loc),\n itemType: typeof item,\n hasLocations: locations.length > 0\n };\n\n // Retry configuration from options or defaults\n const retryConfig = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Creating item (attempt ${attempt + 1})`, operationContext);\n\n const result = await utilities.processOne(api.httpPost<V>(\n utilities.getPath(loc),\n itemToCreate,\n requestOptions,\n ));\n\n utilities.validatePK(result);\n\n if (attempt > 0) {\n logger.info(`Create operation succeeded after ${attempt} retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n\n // Don't retry on the last attempt\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n // Determine if error is retryable\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug('Not retrying create operation due to non-retryable error', {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n attempt: attempt + 1\n });\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`Retrying create operation (attempt ${attempt + 2}) after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n delay,\n attemptNumber: attempt + 1\n });\n\n // Wait before retrying\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n // Handle final error\n const finalError = enhanceError(lastError, operationContext);\n\n // Call custom error handler if provided\n if (apiOptions.errorHandler) {\n try {\n apiOptions.errorHandler(finalError, operationContext);\n } catch (handlerError: any) {\n logger.error('Custom error handler failed', {\n originalError: finalError.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n }\n\n logger.error(`Create operation failed after ${retryConfig.maxRetries + 1} attempts`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n duration: Date.now() - startTime,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n };\n\n return create;\n}\n", "import {\n ComKey,\n Item,\n PriKey,\n UpdateMethod\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'update');\n\nexport const getUpdateOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): UpdateMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const update = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('update', { ik, item, requestOptions });\n\n return await utilities.processOne(\n api.httpPut<V>(\n utilities.getPath(ik),\n item,\n requestOptions,\n ));\n }\n\n return update;\n}\n", "import {\n ComKey,\n Item,\n LocKeyArray,\n PriKey,\n UpdateOptions\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'upsert');\n\nexport const getUpsertOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n ) => {\n\n const upsert = async (\n key: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n item: Partial<Item<S, L1, L2, L3, L4, L5>>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5>,\n options?: UpdateOptions\n ): Promise<V> => {\n const requestOptions = Object.assign({}, apiOptions.putOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('upsert', { key, item, locations, options, requestOptions });\n\n // Add locations to query params if provided\n const path = utilities.getPath(key);\n let url = locations && locations.length > 0\n ? `${path}?locations=${encodeURIComponent(JSON.stringify(locations))}`\n : path;\n\n // Add update options to query params if provided\n if (options) {\n const separator = url.includes('?') ? '&' : '?';\n url += `${separator}options=${encodeURIComponent(JSON.stringify(options))}`;\n }\n\n return await utilities.processOne(\n api.httpPut<V>(\n url,\n { ...item, upsert: true },\n requestOptions,\n ));\n }\n\n return upsert;\n}\n\n", "import {\n ComKey,\n GetMethod,\n Item,\n PriKey,\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\nimport { calculateRetryDelay, enhanceError, shouldRetryError } from \"./errorHandling\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'get');\n\nexport const getGetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): GetMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const get = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n ): Promise<V | null> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.readAuthenticated });\n const keyStr = JSON.stringify(ik);\n \n logger.default('get', { ik, requestOptions });\n\n const operationContext = {\n operation: 'get',\n path: utilities.getPath(ik),\n keyType: typeof ik,\n key: keyStr\n };\n\n logger.debug('CLIENT_API: get() started', {\n ...operationContext,\n isAuthenticated: apiOptions.readAuthenticated\n });\n\n const retryConfig = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n ...apiOptions.retryConfig\n };\n\n let lastError: any = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {\n const attemptStartTime = Date.now();\n try {\n logger.debug(`CLIENT_API: get() attempt ${attempt + 1}`, {\n ...operationContext,\n attempt: attempt + 1,\n maxRetries: retryConfig.maxRetries + 1\n });\n\n const httpStartTime = Date.now();\n const result = await utilities.processOne(\n api.httpGet<V>(\n utilities.getPath(ik),\n requestOptions,\n )\n );\n const httpDuration = Date.now() - httpStartTime;\n\n utilities.validatePK(result);\n\n const attemptDuration = Date.now() - attemptStartTime;\n const totalDuration = Date.now() - startTime;\n\n if (attempt > 0) {\n logger.info(`CLIENT_API: get() succeeded after retries`, {\n ...operationContext,\n totalAttempts: attempt + 1,\n httpDuration,\n attemptDuration,\n totalDuration\n });\n } else {\n logger.debug(`CLIENT_API: get() succeeded (first attempt)`, {\n ...operationContext,\n httpDuration,\n totalDuration,\n hasResult: !!result\n });\n }\n\n return result;\n } catch (error: any) {\n lastError = error;\n const attemptDuration = Date.now() - attemptStartTime;\n\n // Handle 404 errors specially - return null instead of throwing\n if (error.status === 404) {\n logger.debug('CLIENT_API: get() - item not found (404)', {\n ...operationContext,\n attemptDuration,\n totalDuration: Date.now() - startTime\n });\n return null;\n }\n\n logger.debug('CLIENT_API: get() attempt failed', {\n ...operationContext,\n attempt: attempt + 1,\n attemptDuration,\n errorStatus: error.status,\n errorCode: error.code,\n errorMessage: error.message\n });\n\n if (attempt === retryConfig.maxRetries) {\n break;\n }\n\n const isRetryable = shouldRetryError(error);\n if (!isRetryable) {\n logger.debug('CLIENT_API: get() - not retrying (non-retryable error)', {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n errorStatus: error.status,\n attempt: attempt + 1,\n totalDuration: Date.now() - startTime\n });\n break;\n }\n\n const delay = calculateRetryDelay(attempt, retryConfig);\n\n logger.warning(`CLIENT_API: get() - retrying after ${delay}ms`, {\n ...operationContext,\n errorMessage: error.message,\n errorCode: error.code || error.status,\n errorStatus: error.status,\n delay,\n attemptNumber: attempt + 1,\n nextAttempt: attempt + 2,\n maxRetries: retryConfig.maxRetries + 1\n });\n\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n const finalError = enhanceError(lastError, operationContext);\n const totalDuration = Date.now() - startTime;\n\n if (apiOptions.errorHandler) {\n try {\n apiOptions.errorHandler(finalError, operationContext);\n } catch (handlerError: any) {\n logger.error('CLIENT_API: Custom error handler failed', {\n ...operationContext,\n originalError: finalError.message,\n handlerError: handlerError?.message || String(handlerError)\n });\n }\n }\n\n logger.error(`CLIENT_API: get() failed after all retries`, {\n ...operationContext,\n errorMessage: finalError.message,\n errorCode: finalError.code || finalError.status,\n errorStatus: finalError.status,\n totalDuration,\n totalAttempts: retryConfig.maxRetries + 1\n });\n\n throw finalError;\n }\n\n return get;\n}\n", "import {\n ComKey,\n Item,\n PriKey,\n RemoveMethod\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'remove');\n\nexport const getRemoveOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): RemoveMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const remove = async (\n ik: PriKey<S> | ComKey<S, L1, L2, L3, L4, L5>,\n ): Promise<V | void> => {\n const requestOptions = Object.assign({}, apiOptions.deleteOptions, { isAuthenticated: apiOptions.writeAuthenticated });\n logger.default('remove', { ik, requestOptions });\n\n const result = await api.httpDelete<V | boolean | void>(utilities.getPath(ik), requestOptions);\n \n // If result is a boolean, return void for compatibility\n if (typeof result === 'boolean') {\n return;\n }\n \n // Otherwise return the item (if the server returns it)\n return result as V | void;\n }\n\n return remove;\n}\n", "import {\n FindMethod,\n FindOperationResult,\n FindOptions,\n Item,\n LocKeyArray,\n QueryParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { finderToParams } from \"../AItemAPI\";\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'find');\n\nexport const getFindOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FindMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const find = async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = [],\n findOptions?: FindOptions\n ): Promise<FindOperationResult<V>> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n const mergedParams: QueryParams = finderToParams(finder, finderParams);\n \n // Add pagination options to query parameters\n if (findOptions?.limit != null) {\n mergedParams.limit = findOptions.limit.toString();\n }\n if (findOptions?.offset != null) {\n mergedParams.offset = findOptions.offset.toString();\n }\n \n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params: mergedParams });\n logger.default('find', { finder, finderParams, locations, findOptions, requestOptions });\n logger.debug('QUERY_CACHE: client-api.find() - Making API request', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n findOptions,\n path: utilities.getPath(loc),\n params: JSON.stringify(mergedParams),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n // Expect FindOperationResult from server\n const response = await api.httpGet<FindOperationResult<V>>(\n utilities.getPath(loc),\n requestOptions,\n );\n \n // Process items array (convert dates, etc.)\n const processedItems = await utilities.processArray(Promise.resolve(response.items || []));\n \n logger.debug('QUERY_CACHE: client-api.find() - API response received', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n itemCount: processedItems.length,\n total: response.metadata?.total || 0,\n itemKeys: processedItems.map(item => JSON.stringify(item.key))\n });\n\n return {\n items: processedItems,\n metadata: response.metadata\n };\n }\n\n return find as unknown as FindMethod<V, S, L1, L2, L3, L4, L5>;\n}\n", "import {\n FindOneMethod,\n Item,\n LocKeyArray,\n QueryParams\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { finderToParams } from \"../AItemAPI\";\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'find');\n\nexport const getFindOneOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FindOneMethod<V, S, L1, L2, L3, L4, L5> => {\n\n const findOne = async (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V> => {\n utilities.verifyLocations(locations);\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n const params: QueryParams = finderToParams(finder, finderParams);\n params.one = true;\n\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.allAuthenticated, params });\n logger.default('findOne', { finder, finderParams, locations, requestOptions });\n logger.debug('QUERY_CACHE: client-api.findOne() - Making API request', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n path: utilities.getPath(loc),\n params: JSON.stringify(params),\n isAuthenticated: apiOptions.allAuthenticated\n });\n\n const results = await utilities.processArray(\n api.httpGet<V[]>(\n utilities.getPath(loc),\n requestOptions,\n ));\n \n const result = results[0];\n if (result) {\n utilities.validatePK(result);\n logger.debug('QUERY_CACHE: client-api.findOne() - API response received', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations),\n itemKey: JSON.stringify(result.key)\n });\n } else {\n logger.debug('QUERY_CACHE: client-api.findOne() - API returned no items', {\n finder,\n finderParams: JSON.stringify(finderParams),\n locations: JSON.stringify(locations)\n });\n }\n \n return result;\n }\n\n return findOne;\n}\n", "import {\n ComKey,\n FacetOperationMethod,\n Item,\n PriKey,\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'facet');\n\nexport const getFacetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): FacetOperationMethod<S, L1, L2, L3, L4, L5> => {\n\n /**\n * Executes a facet operation on an item.\n *\n * A facet is a piece of information that is related to an item - it represents\n * a specific aspect or characteristic of the item. Unlike actions which may\n * return items or perform operations, facets are informational queries that\n * return data about a particular facet of an item.\n *\n * @param ik - The item key (composite or primary key) identifying the item\n * @param facet - The name of the facet to query\n * @param body - Optional request body for the facet operation\n * @param options - Optional HTTP request options\n * @returns Promise resolving to the facet data\n */\n const facet = async (\n ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>,\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n ): Promise<any> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.writeAuthenticated, params });\n logger.default('facet', { ik, facet, requestOptions });\n\n return api.httpGet<any>(\n `${utilities.getPath(ik)}/${facet}`,\n requestOptions,\n );\n\n };\n\n return facet;\n}\n", "import {\n AllFacetOperationMethod,\n Item,\n LocKeyArray\n} from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"../ClientApiOptions\";\nimport LibLogger from \"../logger\";\nimport { Utilities } from \"../Utilities\";\n\nconst logger = LibLogger.get('client-api', 'ops', 'allFacet');\n\nexport const getAllFacetOperation = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>\n\n ): AllFacetOperationMethod<L1, L2, L3, L4, L5> => {\n\n const allFacet = async (\n facet: string,\n params: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>> = {},\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] = []\n ): Promise<V[]> => {\n const requestOptions = Object.assign({}, apiOptions.getOptions, { isAuthenticated: apiOptions.writeAuthenticated, params });\n logger.default('allFacet', { facet, locations, requestOptions });\n utilities.verifyLocations(locations);\n\n const loc: LocKeyArray<L1, L2, L3, L4, L5> | [] = locations;\n\n // TODO: This should respond to either a single object, or multiple objects in an array.\n return api.httpGet<V[]>(\n `${utilities.getPath(loc)}/${facet}`,\n requestOptions,\n )\n };\n\n return allFacet;\n}\n", "/* eslint-disable indent */\nimport { Item } from \"@fjell/core\"\nimport { getAllOperation } from \"./all\"\nimport { getActionOperation } from \"./action\"\nimport { Utilities } from \"../Utilities\"\nimport { HttpApi } from \"@fjell/http-api\"\nimport { getAllActionOperation } from \"./allAction\"\nimport { getOneOperation } from \"./one\"\nimport { getCreateOperation } from \"./create\"\nimport { getUpdateOperation } from \"./update\"\nimport { getUpsertOperation } from \"./upsert\"\nimport { getGetOperation } from \"./get\"\nimport { getRemoveOperation } from \"./remove\"\nimport { getFindOperation } from \"./find\"\nimport { ClientApiOptions } from \"../ClientApiOptions\"\nimport { ClientApi } from \"../ClientApi\"\nimport { getFindOneOperation } from \"./findOne\"\nimport { getFacetOperation } from \"./facet\"\nimport { getAllFacetOperation } from \"./allFacet\"\n\nexport const getOperations =\n <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never>(\n api: HttpApi,\n apiOptions: ClientApiOptions,\n utilities: Utilities<V, S, L1, L2, L3, L4, L5>,\n\n ): ClientApi<V, S, L1, L2, L3, L4, L5> => {\n return {\n action: getActionOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n all: getAllOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n allAction: getAllActionOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n allFacet: getAllFacetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n create: getCreateOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n facet: getFacetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n findOne: getFindOneOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n find: getFindOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n get: getGetOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n one: getOneOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n remove: getRemoveOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n update: getUpdateOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n upsert: getUpsertOperation<V, S, L1, L2, L3, L4, L5>(\n api,\n apiOptions,\n utilities,\n ),\n }\n }", "import {\n ComKey,\n validatePK as coreValidatePK,\n generateKeyArray,\n isPriKey,\n Item,\n LocKey,\n LocKeyArray,\n PriKey,\n} from \"@fjell/core\";\n\nimport LibLogger from \"./logger\";\nimport deepmerge from \"deepmerge\";\n\nconst logger = LibLogger.get('client-api', 'Utility');\n\nexport interface Utilities<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> {\n verifyLocations: (locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never) => boolean;\n processOne: (apiCall: Promise<V>) => Promise<V>;\n processArray: (api: Promise<V[]>) => Promise<V[]>;\n convertDoc: (doc: V) => V;\n getPath: (key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | []) => string;\n validatePK: (item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]) =>\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[];\n}\n\nexport const createUtilities = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(pkType: S, pathNames: string[]): Utilities<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createUtilities', { pkType, pathNames });\n\n const verifyLocations = (\n locations: LocKeyArray<L1, L2, L3, L4, L5> | [] | never,\n ): boolean => {\n\n if (locations && locations.length < pathNames.length - 1) {\n throw new Error('Not enough locations for pathNames: locations:'\n + locations.length + ' pathNames:' + pathNames.length);\n }\n return true;\n }\n\n const processOne = async (\n apiCall: Promise<V>,\n ): Promise<V> => {\n logger.default('processOne', { apiCall });\n const response = await apiCall;\n logger.default('processOne response', {\n responseType: typeof response,\n hasData: !!response\n });\n return convertDoc(response);\n };\n\n const processArray = async (\n api: Promise<V[]>,\n ): Promise<V[]> => {\n logger.default('processArray', { api });\n const response = await api;\n logger.default('processArray response', {\n responseType: typeof response,\n isArray: Array.isArray(response),\n length: Array.isArray(response) ? response.length : 0\n });\n if (response && Array.isArray(response)) {\n return response.map((subjectChat: V) =>\n convertDoc(subjectChat),\n ) as unknown as V[];\n } else {\n logger.error('Response was not an array', { response });\n throw new Error('Response was not an array');\n }\n };\n\n const convertDoc = (doc: V): V => {\n logger.default('convertDoc', { doc });\n // console.log(JSON.stringify(doc, null, 2));\n if (doc && doc.events) {\n const events = doc.events;\n for (const key in events) {\n events[key] = deepmerge(events[key], { at: events[key].at ? new Date(events[key].at) : null });\n }\n\n return doc as unknown as V;\n } else {\n return doc;\n }\n };\n\n const getPath =\n (\n key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S> | LocKeyArray<L1, L2, L3, L4, L5> | [],\n ):\n string => {\n\n const localPathNames = [...pathNames];\n logger.default('getPath', { key, pathNames: localPathNames });\n\n // console.log('getPath key: ' + JSON.stringify(key));\n\n const keys = generateKeyArray(key);\n\n // console.log('getPath keys: ' + JSON.stringify(keys));\n // console.log('getPath pathNames: ' + JSON.stringify(pathNames));\n\n // For contained items (ComKey), we need to process location keys first\n // to match the URL structure: /parents/{parentId}/children/{childId}\n if (keys.length > 1) {\n // Separate PriKeys and LocKeys\n const priKeys = keys.filter(k => isPriKey(k));\n const locKeys = keys.filter(k => !isPriKey(k));\n \n // Location keys come in child->parent order, but paths must be parent->child\n // So reverse the locKeys to get parent->child order for path building\n const reversedLocKeys = [...locKeys].reverse();\n \n // Reorder: reversed LocKeys first, then PriKeys\n const reorderedKeys = [...reversedLocKeys, ...priKeys];\n logger.default('Reordered keys for contained item', {\n original: keys,\n locKeys,\n reversedLocKeys,\n reordered: reorderedKeys,\n priKeys\n });\n \n let path: string = addPath('', reorderedKeys, localPathNames);\n\n // If there is only one collection left in the collections array, this means that\n // we received LocKeys and we need to add the last collection to the reference\n if (localPathNames.length === 1) {\n path = `${path}/${localPathNames[0]}`;\n }\n\n logger.default('getPath created', { key, path });\n return path;\n } else {\n // For primary items or single keys\n // If it's a LocKey array, we still need to reverse it for path building\n const priKeys = keys.filter(k => isPriKey(k));\n const locKeys = keys.filter(k => !isPriKey(k));\n \n // Reverse locKeys if present (child->parent to parent->child)\n const reversedLocKeys = locKeys.length > 0 ? [...locKeys].reverse() : [];\n const orderedKeys = [...reversedLocKeys, ...priKeys];\n \n let path: string = addPath('', orderedKeys, localPathNames);\n\n // If there is only one collection left in the collections array, this means that\n // we received LocKeys and we need to add the last collection to the reference\n if (localPathNames.length === 1) {\n path = `${path}/${localPathNames[0]}`;\n }\n\n logger.default('getPath created', { key, path });\n return path;\n }\n };\n\n const addPath = (\n base: string,\n keys: Array<PriKey<S> | LocKey<L1 | L2 | L3 | L4 | L5>>,\n localPathNames: string[],\n ): string => {\n logger.default('addPath', { base, keys, pathNames: localPathNames });\n if (keys.length < localPathNames.length - 1) {\n logger.error('addPath should never have keys with a length less than the length of pathNames - 1',\n { keys, localPathNames });\n throw new Error('addPath should never have keys with a length less than the length of pathNames - 1: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n } else if (keys.length > localPathNames.length) {\n logger.error('addPath should never have keys with a length greater than the length of pathNames',\n { keys, pathNames });\n throw new Error('addPath should never have keys with a length greater than the length of pathNames: '\n + keys.length + ' ' + localPathNames.length + ' ' + JSON.stringify(keys, localPathNames));\n }\n if (keys.length === 0) {\n // If you've recursively consumed all of the keys, return the base.\n logger.default('addPath returning base', { base });\n return base;\n } else {\n const currentKey = keys[0];\n const keyType = isPriKey(currentKey) ? currentKey.kt : currentKey.kt;\n \n // Find the best matching pathName for this key type\n const matchingPathNameIndex = localPathNames.findIndex(pathName => {\n const singularPathName = pathName.endsWith('s') ? pathName.slice(0, -1) : pathName;\n const pluralKeyType = keyType + 's';\n \n // Try various matching strategies\n return pathName === pluralKeyType || // photos === photo+s\n pathName === keyType + 'es' || // matches === match+es\n singularPathName === keyType || // photo === photo\n pathName.toLowerCase() === keyType.toLowerCase() || // case insensitive\n pathName.toLowerCase() === pluralKeyType.toLowerCase(); // case insensitive plural\n });\n \n if (matchingPathNameIndex !== -1) {\n // Found a matching pathName\n const pathName = localPathNames.splice(matchingPathNameIndex, 1)[0];\n const key = keys.shift()!;\n const id = isPriKey(key) ? (key as PriKey<S>).pk : (key as LocKey<L1 | L2 | L3 | L4 | L5>).lk;\n const nextBase = `${base}/${pathName}/${id}`;\n logger.default('Adding Path (matched)', {\n pathName,\n keyType,\n isPriKey: isPriKey(key),\n key,\n nextBase\n });\n return addPath(nextBase, keys, localPathNames);\n } else {\n // No match found, use first available pathName\n const pathName = localPathNames.shift()!;\n const key = keys.shift()!;\n const id = isPriKey(key) ? (key as PriKey<S>).pk : (key as LocKey<L1 | L2 | L3 | L4 | L5>).lk;\n const nextBase = `${base}/${pathName}/${id}`;\n logger.default('Adding Path (no match, using first)', {\n pathName,\n keyType,\n isPriKey: isPriKey(key),\n key,\n nextBase\n });\n return addPath(nextBase, keys, localPathNames);\n }\n }\n\n }\n\n const validatePK = (\n item: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[]):\n Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {\n return coreValidatePK<S, L1, L2, L3, L4, L5>(item, pkType);\n }\n\n return {\n verifyLocations,\n processOne,\n convertDoc,\n processArray,\n getPath,\n validatePK,\n }\n}\n", "/* eslint-disable indent */\nimport { Item } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\n\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nimport { getOperations } from \"./ops\";\nimport { createUtilities } from \"./Utilities\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"./logger\";\n\nconst logger = LibLogger.get('AItemAPI');\n\nexport type PathNamesArray<\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> =\n ([L5] extends [never] ?\n ([L4] extends [never] ?\n ([L3] extends [never] ?\n ([L2] extends [never] ?\n ([L1] extends [never] ?\n [string] :\n [string, string]) :\n [string, string, string]) :\n [string, string, string, string]) :\n [string, string, string, string, string]) :\n [string, string, string, string, string, string]);\n\nexport const finderToParams = (\n finder: string,\n finderParams: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>\n): Record<string, string> => {\n return {\n finder,\n finderParams: JSON.stringify(finderParams),\n };\n};\n\nexport const createAItemAPI = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n api: HttpApi,\n pkType: S,\n pathNames: PathNamesArray<L1, L2, L3, L4, L5>,\n options?: ClientApiOptions,\n): ClientApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createAItemAPI', { pkType, pathNames, options });\n\n let mergedOptions: ClientApiOptions;\n\n const defaultOptions: ClientApiOptions = {\n readAuthenticated: true,\n allAuthenticated: true,\n writeAuthenticated: true,\n getOptions: {},\n postOptions: {},\n putOptions: {},\n deleteOptions: {},\n };\n\n if (options) {\n mergedOptions = Object.assign({}, defaultOptions, options);\n } else {\n mergedOptions = defaultOptions;\n }\n\n const utilities = createUtilities<V, S, L1, L2, L3, L4, L5>(pkType, pathNames);\n const operations = getOperations<V, S, L1, L2, L3, L4, L5>(api, mergedOptions, utilities);\n\n return {\n action: operations.action,\n all: operations.all,\n allAction: operations.allAction,\n allFacet: operations.allFacet,\n create: operations.create,\n facet: operations.facet,\n find: operations.find,\n findOne: operations.findOne,\n get: operations.get,\n one: operations.one,\n remove: operations.remove,\n update: operations.update,\n upsert: operations.upsert,\n }\n}", "\nimport {\n AllOperationResult,\n AllOptions,\n FindOperationResult,\n FindOptions,\n Item,\n ItemQuery,\n LocKeyArray,\n} from \"@fjell/core\";\nimport {\n HttpApi\n} from \"@fjell/http-api\";\nimport { createAItemAPI, PathNamesArray } from \"./AItemAPI\";\n\nimport LibLogger from \"./logger\";\nimport { ClientApi } from \"./ClientApi\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\n\nconst logger = LibLogger.get('CItemAPI');\n\n/**\n * CItemApi extends ClientApi for contained items.\n * No additional methods needed - pure Operations interface.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface CItemApi<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never,\n> extends ClientApi<V, S, L1, L2, L3, L4, L5> {\n // Inherits all methods from ClientApi (which extends core Operations)\n}\n\n/**\n * Helper function to ensure items are extracted from { items, metadata } response structure.\n * This provides defensive handling in case the underlying API doesn't extract items properly.\n */\nfunction ensureItemsExtracted<T>(\n result: any,\n operationName: string\n): { items: T[]; metadata: any } {\n // If result already has the correct structure with items array, return as-is\n if (result && typeof result === 'object' && Array.isArray(result.items)) {\n return result;\n }\n \n // If result is the raw { items, metadata } structure but items wasn't extracted\n if (result && typeof result === 'object' && 'items' in result && 'metadata' in result) {\n logger.debug(`${operationName}: Extracting items from response structure`, {\n hasItems: Array.isArray(result.items),\n itemsType: typeof result.items,\n itemsLength: Array.isArray(result.items) ? result.items.length : 'N/A'\n });\n return {\n items: Array.isArray(result.items) ? result.items : [],\n metadata: result.metadata || {}\n };\n }\n \n // If result is an array (legacy format), wrap it\n if (Array.isArray(result)) {\n logger.debug(`${operationName}: Wrapping array result in { items, metadata } structure`);\n return {\n items: result,\n metadata: {\n total: result.length,\n returned: result.length,\n offset: 0,\n hasMore: false\n }\n };\n }\n \n // Fallback: return empty result\n logger.warning(`${operationName}: Unexpected response format, returning empty result`, {\n resultType: typeof result,\n resultKeys: result && typeof result === 'object' ? Object.keys(result) : []\n });\n return {\n items: [],\n metadata: {}\n };\n}\n\nexport const createCItemApi = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(api: HttpApi, type: S, pathNames: PathNamesArray<L1, L2, L3, L4, L5>, options?: ClientApiOptions): CItemApi<V, S, L1, L2, L3, L4, L5> => {\n\n logger.default('createCItemApi', { api, type, pathNames, options });\n\n const aItemAPI = createAItemAPI(api, type, pathNames, options);\n\n // Wrap methods that return { items, metadata } to ensure items are always extracted\n const all = async (\n query?: ItemQuery,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | [],\n allOptions?: AllOptions\n ): Promise<AllOperationResult<V>> => {\n const result = allOptions != null\n ? await aItemAPI.all(query, locations, allOptions)\n : await aItemAPI.all(query, locations);\n const extracted = ensureItemsExtracted<V>(result, 'all');\n return extracted as AllOperationResult<V>;\n };\n\n const find = async (\n finder: string,\n finderParams?: Record<string, string | number | boolean | Date | Array<string | number | boolean | Date>>,\n locations?: LocKeyArray<L1, L2, L3, L4, L5> | [],\n findOptions?: FindOptions\n ): Promise<FindOperationResult<V>> => {\n const result = findOptions != null\n ? await aItemAPI.find(finder, finderParams, locations, findOptions)\n : await aItemAPI.find(finder, finderParams, locations);\n const extracted = ensureItemsExtracted<V>(result, 'find');\n return extracted as FindOperationResult<V>;\n };\n\n return {\n action: aItemAPI.action,\n all,\n allAction: aItemAPI.allAction,\n allFacet: aItemAPI.allFacet,\n one: aItemAPI.one,\n get: aItemAPI.get,\n create: aItemAPI.create,\n remove: aItemAPI.remove,\n update: aItemAPI.update,\n upsert: aItemAPI.upsert,\n facet: aItemAPI.facet,\n find,\n findOne: aItemAPI.findOne,\n } as unknown as CItemApi<V, S, L1, L2, L3, L4, L5>;\n}\n", "import { AllOperationResult, AllOptions, ComKey, FindOperationResult, FindOptions, Item, ItemQuery, PriKey } from \"@fjell/core\";\nimport { HttpApi } from \"@fjell/http-api\";\nimport { createAItemAPI } from \"./AItemAPI\";\nimport { ClientApi } from \"./ClientApi\";\n\nimport LibLogger from \"./logger\";\nimport { ClientApiOptions } from \"./ClientApiOptions\";\nconst logger = LibLogger.get('PItemAPI');\n\n/**\n * Helper function to ensure items are extracted from { items, metadata } response structure.\n * This provides defensive handling in case the underlying API doesn't extract items properly.\n */\nfunction ensureItemsExtracted<T>(\n result: any,\n operationName: string\n): { items: T[]; metadata: any } {\n // If result already has the correct structure with items array, return as-is\n if (result && typeof result === 'object' && Array.isArray(result.items)) {\n return result;\n }\n \n // If result is the raw { items, metadata } structure but items wasn't extracted\n if (result && typeof result === 'object' && 'items' in result && 'metadata' in result) {\n logger.debug(`${operationName}: Extracting items from response structure`, {\n hasItems: Array.isArray(result.items),\n itemsType: typeof result.items,\n itemsLength: Array.isArray(result.items) ? result.items.length : 'N/A'\n });\n return {\n items: Array.isArray(result.items) ? result.items : [],\n metadata: result.metadata || {}\n };\n }\n \n // If result is an array (legacy format), wrap it\n if (Array.isArray(result)) {\n logger.debug(`${operationName}: Wrapping array result in { items, metadata } structure`);\n return {\n items: result,\n metadata: {\n total: result.length,\n returned: result.length,\n offset: 0,\n hasMore: false\n }\n };\n }\n \n // Fallback: return empty result\n logger.warning(`${operationName}: Unexpected response format, returning empty result`, {\n resultType: typeof result,\n resultKeys: result && typeof result === 'object' ? Object.keys(result) : []\n });\n return {\n items: [],\n metadata: {}\n };\n}\n\n// PItemApi now directly extends ClientApi without re-declaring methods\n// This ensures compatibility with core Operations interface\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface PItemApi<\n V extends Item<S>,\n S extends string\n> extends ClientApi<V, S> {\n // Inherits all methods from ClientApi\n}\n\nexport const createPItemApi = <V extends Item<S>, S extends string>(\n api: HttpApi,\n type: S,\n pathName: string,\n options?: ClientApiOptions\n): PItemApi<V, S> => {\n\n logger.default('createPItemApi', { type, pathName, options });\n\n const aItemAPI = createAItemAPI<V, S>(api, type, [pathName], options);\n\n // Simplified wrapper functions that adapt to primary-only API (no locations)\n const action = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n action: string,\n params?: any,\n ) => await aItemAPI.action(ik, action, params);\n\n const all = async (query?: ItemQuery, locations?: [], allOptions?: AllOptions): Promise<AllOperationResult<V>> => {\n const result = await aItemAPI.all(query || {}, locations || [], allOptions);\n const extracted = ensureItemsExtracted<V>(result, 'all');\n return extracted as AllOperationResult<V>;\n };\n\n const allAction = async (action: string, params?: any) =>\n await aItemAPI.allAction(action, params, []);\n\n const allFacet = async (facet: string, params?: any) =>\n await aItemAPI.allFacet(facet, params);\n\n const one = async (query?: ItemQuery) =>\n await aItemAPI.one(query || {}, []);\n\n const get = async (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) =>\n await aItemAPI.get(ik);\n\n const create = async (item: Partial<Item<S>>, options?: any) =>\n await aItemAPI.create(item, options);\n\n const remove = async (ik: PriKey<S> | ComKey<S, never, never, never, never, never>) =>\n await aItemAPI.remove(ik);\n\n const update = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: Partial<Item<S>>,\n ) => await aItemAPI.update(ik, item);\n\n const upsert = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n item: Partial<Item<S>>,\n locations?: any\n ) => await aItemAPI.upsert(ik, item, locations);\n\n const facet = async (\n ik: PriKey<S> | ComKey<S, never, never, never, never, never>,\n facet: string,\n params?: any,\n ) => await aItemAPI.facet(ik, facet, params);\n\n const find = async (finder: string, finderParams?: any, locations?: [], findOptions?: FindOptions): Promise<FindOperationResult<V>> => {\n const result = await (aItemAPI.find as any)(finder, finderParams, locations || [], findOptions);\n const extracted = ensureItemsExtracted<V>(result, 'find');\n return extracted as FindOperationResult<V>;\n };\n\n const findOne = async (finder: string, finderParams?: any) =>\n await aItemAPI.findOne(finder, finderParams);\n\n return {\n action,\n all,\n allAction,\n allFacet,\n one,\n get,\n create,\n remove,\n update,\n upsert,\n facet,\n find,\n findOne,\n } as PItemApi<V, S>;\n\n};\n", "\nimport LibLogger from \"./logger\";\nimport { Item } from \"@fjell/core\";\nimport { Instance as BaseInstance, createInstance as createBaseInstance, Registry } from \"@fjell/registry\";\nimport { ClientApi } from \"./ClientApi\";\nimport { Coordinate } from \"@fjell/core\";\n\nconst logger = LibLogger.get(\"Instance\");\n\n/**\n * The Client API Instance interface represents a client API model instance that extends the base Instance\n * from @fjell/registry and adds client API operations for interacting with remote data.\n *\n * The interface extends the base Instance (which provides coordinate and registry) with:\n * - clientApi: Provides methods for interacting with remote data through HTTP APIs (get, create, update, etc.)\n *\n * @template V - The type of the data model item, extending Item\n * @template S - The string literal type representing the model's key type\n * @template L1-L5 - Optional string literal types for location hierarchy levels\n */\nexport interface Instance<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends BaseInstance<S, L1, L2, L3, L4, L5> {\n /** The client API object that provides methods for interacting with remote data */\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>;\n}\n\nexport const createInstance = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n registry: Registry,\n coordinate: Coordinate<S, L1, L2, L3, L4, L5>,\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>,\n ): Instance<V, S, L1, L2, L3, L4, L5> => {\n logger.debug(\"createInstance\", { coordinate, clientApi, registry });\n const baseInstance = createBaseInstance(registry, coordinate);\n return { ...baseInstance, clientApi };\n}\n", "import { Item } from \"@fjell/core\";\nimport { ClientApi } from \"./ClientApi\";\nimport { InstanceFactory as BaseInstanceFactory, Registry, RegistryHub } from \"@fjell/registry\";\nimport { createInstance, Instance } from \"./Instance\";\nimport { Coordinate } from \"@fjell/core\";\nimport LibLogger from \"./logger\";\n\nconst logger = LibLogger.get(\"InstanceFactory\");\n\nexport type InstanceFactory<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> = (\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n) => BaseInstanceFactory<S, L1, L2, L3, L4, L5>;\n\n/**\n * Factory function for creating client-api instances\n */\nexport const createInstanceFactory = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n clientApi: ClientApi<V, S, L1, L2, L3, L4, L5>\n ): BaseInstanceFactory<S, L1, L2, L3, L4, L5> => {\n return (coordinate: Coordinate<S, L1, L2, L3, L4, L5>, context: { registry: Registry, registryHub?: RegistryHub }) => {\n logger.debug(\"Creating client-api instance\", { coordinate, registry: context.registry, clientApi });\n\n return createInstance(context.registry, coordinate, clientApi) as Instance<V, S, L1, L2, L3, L4, L5>;\n };\n};\n", "import LibLogger from './logger';\nimport {\n Registry as BaseRegistry,\n createRegistry as createBaseRegistry,\n RegistryFactory,\n RegistryHub\n} from '@fjell/registry';\n\nconst logger = LibLogger.get(\"Registry\");\n\n/**\n * Extended Registry interface for client-api-specific functionality\n */\nexport interface Registry extends BaseRegistry {\n type: 'client-api';\n}\n\n/**\n * Factory function for creating client-api registries\n */\nexport const createRegistryFactory = (): RegistryFactory => {\n return (type: string, registryHub?: RegistryHub): BaseRegistry => {\n if (type !== 'client-api') {\n throw new Error(`Client API registry factory can only create 'client-api' type registries, got: ${type}`);\n }\n\n logger.debug(\"Creating client-api registry\", { type, registryHub });\n\n const baseRegistry = createBaseRegistry(type, registryHub);\n\n // Cast to Registry for type safety\n return baseRegistry as Registry;\n };\n};\n\n/**\n * Creates a new client-api registry instance\n */\nexport const createRegistry = (registryHub?: RegistryHub): Registry => {\n const baseRegistry = createBaseRegistry('client-api', registryHub);\n\n return {\n ...baseRegistry,\n } as Registry;\n};\n", "/**\n * Base class for all Client API errors\n */\nexport abstract class ClientApiError extends Error {\n abstract readonly code: string;\n abstract readonly isRetryable: boolean;\n readonly timestamp: Date;\n readonly context?: Record<string, any>;\n\n constructor(message: string, context?: Record<string, any>) {\n super(message);\n this.name = this.constructor.name;\n this.timestamp = new Date();\n this.context = context;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n isRetryable: this.isRetryable,\n timestamp: this.timestamp,\n context: this.context,\n stack: this.stack\n };\n }\n}\n\n/**\n * Network-related errors (connection issues, timeouts)\n */\nexport class NetworkError extends ClientApiError {\n readonly code = 'NETWORK_ERROR';\n readonly isRetryable = true;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Network error: ${message}`, context);\n }\n}\n\n/**\n * HTTP timeout errors\n */\nexport class TimeoutError extends ClientApiError {\n readonly code = 'TIMEOUT_ERROR';\n readonly isRetryable = true;\n\n constructor(timeout: number, context?: Record<string, any>) {\n super(`Request timed out after ${timeout}ms`, context);\n }\n}\n\n/**\n * Authentication errors (401 Unauthorized)\n */\nexport class AuthenticationError extends ClientApiError {\n readonly code = 'AUTHENTICATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message?: string, context?: Record<string, any>) {\n super(message || 'Authentication failed - invalid or expired credentials', context);\n }\n}\n\n/**\n * Authorization errors (403 Forbidden)\n */\nexport class AuthorizationError extends ClientApiError {\n readonly code = 'AUTHORIZATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message?: string, context?: Record<string, any>) {\n super(message || 'Access forbidden - insufficient permissions', context);\n }\n}\n\n/**\n * Resource not found errors (404 Not Found)\n */\nexport class NotFoundError extends ClientApiError {\n readonly code = 'NOT_FOUND_ERROR';\n readonly isRetryable = false;\n\n constructor(resource: string, identifier?: string, context?: Record<string, any>) {\n const message = identifier\n ? `${resource} with identifier '${identifier}' not found`\n : `${resource} not found`;\n super(message, context);\n }\n}\n\n/**\n * Request validation errors (400 Bad Request)\n */\nexport class ValidationError extends ClientApiError {\n readonly code = 'VALIDATION_ERROR';\n readonly isRetryable = false;\n readonly validationErrors?: Array<{ field: string; message: string }>;\n\n constructor(message: string, validationErrors?: Array<{ field: string; message: string }>, context?: Record<string, any>) {\n super(`Validation error: ${message}`, context);\n this.validationErrors = validationErrors;\n }\n}\n\n/**\n * Conflict errors (409 Conflict)\n */\nexport class ConflictError extends ClientApiError {\n readonly code = 'CONFLICT_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Conflict: ${message}`, context);\n }\n}\n\n/**\n * Rate limiting errors (429 Too Many Requests)\n */\nexport class RateLimitError extends ClientApiError {\n readonly code = 'RATE_LIMIT_ERROR';\n readonly isRetryable = true;\n readonly retryAfter?: number;\n\n constructor(retryAfter?: number, context?: Record<string, any>) {\n const message = retryAfter\n ? `Rate limit exceeded - retry after ${retryAfter} seconds`\n : 'Rate limit exceeded';\n super(message, context);\n this.retryAfter = retryAfter;\n }\n}\n\n/**\n * Server errors (5xx status codes)\n */\nexport class ServerError extends ClientApiError {\n readonly code = 'SERVER_ERROR';\n readonly isRetryable = true;\n readonly statusCode: number;\n\n constructor(statusCode: number, message?: string, context?: Record<string, any>) {\n super(message || `Server error (${statusCode})`, context);\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Request payload too large errors (413)\n */\nexport class PayloadTooLargeError extends ClientApiError {\n readonly code = 'PAYLOAD_TOO_LARGE_ERROR';\n readonly isRetryable = false;\n\n constructor(maxSize?: string, context?: Record<string, any>) {\n const message = maxSize\n ? `Request payload too large - maximum size is ${maxSize}`\n : 'Request payload too large';\n super(message, context);\n }\n}\n\n/**\n * Generic HTTP errors for unhandled status codes\n */\nexport class HttpError extends ClientApiError {\n readonly code = 'HTTP_ERROR';\n readonly isRetryable: boolean;\n readonly statusCode: number;\n readonly statusText: string;\n\n constructor(statusCode: number, statusText: string, message?: string, context?: Record<string, any>) {\n super(message || `HTTP error ${statusCode}: ${statusText}`, context);\n this.statusCode = statusCode;\n this.statusText = statusText;\n\n // 5xx errors are generally retryable, 4xx are not\n this.isRetryable = statusCode >= 500;\n }\n}\n\n/**\n * Configuration errors\n */\nexport class ConfigurationError extends ClientApiError {\n readonly code = 'CONFIGURATION_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Configuration error: ${message}`, context);\n }\n}\n\n/**\n * Parse/serialization errors\n */\nexport class ParseError extends ClientApiError {\n readonly code = 'PARSE_ERROR';\n readonly isRetryable = false;\n\n constructor(message: string, context?: Record<string, any>) {\n super(`Parse error: ${message}`, context);\n }\n}\n\n/**\n * Create appropriate error from HTTP response\n */\nexport function createHttpError(\n statusCode: number,\n statusText: string,\n responseBody?: any,\n context?: Record<string, any>\n): ClientApiError {\n const errorContext = { statusCode, statusText, responseBody, ...context };\n\n switch (statusCode) {\n case 400:\n if (responseBody?.validationErrors) {\n return new ValidationError(\n responseBody.message || 'Request validation failed',\n responseBody.validationErrors,\n errorContext\n );\n }\n return new ValidationError(responseBody?.message || statusText, [], errorContext);\n\n case 401:\n return new AuthenticationError(responseBody?.message, errorContext);\n\n case 403:\n return new AuthorizationError(responseBody?.message, errorContext);\n\n case 404:\n return new NotFoundError(\n responseBody?.resource || 'Resource',\n responseBody?.identifier,\n errorContext\n );\n\n case 409:\n return new ConflictError(responseBody?.message || statusText, errorContext);\n\n case 413:\n return new PayloadTooLargeError(responseBody?.maxSize, errorContext);\n\n case 429: {\n let retryAfter: number | undefined;\n if (responseBody?.retryAfter) {\n retryAfter = responseBody.retryAfter;\n } else if (context?.headers?.['retry-after']) {\n retryAfter = parseInt(context.headers['retry-after']);\n }\n return new RateLimitError(retryAfter, errorContext);\n }\n\n default:\n if (statusCode >= 500) {\n return new ServerError(statusCode, responseBody?.message || statusText, errorContext);\n }\n\n return new HttpError(statusCode, statusText, responseBody?.message, errorContext);\n }\n}\n\n/**\n * Create appropriate error from network/connection issues\n */\nexport function createNetworkError(error: any, context?: Record<string, any>): ClientApiError {\n const errorContext = { originalError: error, ...context };\n\n if (error.code === 'ECONNABORTED' || error.message?.includes('timeout')) {\n return new TimeoutError(error.timeout || 5000, errorContext);\n }\n\n if (error.code === 'ECONNREFUSED' ||\n error.code === 'ENOTFOUND' ||\n error.code === 'ENETUNREACH' ||\n error.message?.includes('network')) {\n return new NetworkError(error.message || 'Network connection failed', errorContext);\n }\n\n // For unknown errors, treat as network issues that might be retryable\n return new NetworkError(error.message || 'Unknown network error', errorContext);\n}\n\n/**\n * Type guard to check if error is retryable\n */\nexport function isRetryableError(error: any): boolean {\n return error instanceof ClientApiError && error.isRetryable;\n}\n\n/**\n * Type guard to check if error is a Client API error\n */\nexport function isClientApiError(error: any): error is ClientApiError {\n return error instanceof ClientApiError;\n}\n", "export type { CItemApi } from \"./CItemAPI\";\nexport type { PItemApi } from \"./PItemAPI\";\nexport type { ClientApi } from \"./ClientApi\";\nexport type { ClientApiOptions } from \"./ClientApiOptions\";\n\nexport { createCItemApi } from \"./CItemAPI\";\nexport { createPItemApi } from \"./PItemAPI\";\n\n// Registry components\nexport * from './Instance';\nexport * from './InstanceFactory';\nexport * from './Registry';\n\n// Error handling\nexport * from './errors/index';\nexport * from './ops/errorHandling';\n\n// Re-export FjellHttpError from http-api for convenience\nexport { FjellHttpError, isFjellHttpError, extractErrorInfo, type ErrorInfo } from '@fjell/http-api';\n\n// HTTP wrapper\nexport * from './http/HttpWrapper';\n", "import { HttpApi } from '@fjell/http-api';\nimport {\n ClientApiError,\n createHttpError,\n createNetworkError,\n RateLimitError\n} from '../errors/index';\n\n// Simple logger interface for now\nconst logger = {\n debug: (message: string, context?: any) => console.debug(message, context),\n info: (message: string, context?: any) => console.info(message, context),\n warning: (message: string, context?: any) => console.warn(message, context),\n error: (message: string, context?: any) => console.error(message, context)\n};\n\n/**\n * Configuration for retry behavior\n */\nexport interface RetryConfig {\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n /** Initial delay between retries in milliseconds (default: 1000) */\n initialDelayMs?: number;\n /** Maximum delay between retries in milliseconds (default: 30000) */\n maxDelayMs?: number;\n /** Backoff multiplier for exponential backoff (default: 2) */\n backoffMultiplier?: number;\n /** Whether to add jitter to retry delays (default: true) */\n enableJitter?: boolean;\n /** Custom function to determine if an error should be retried */\n shouldRetry?: (error: ClientApiError, attemptNumber: number) => boolean;\n /** Called before each retry attempt */\n onRetry?: (error: ClientApiError, attemptNumber: number, delay: number) => void;\n}\n\n/**\n * Default retry configuration\n */\nconst DEFAULT_RETRY_CONFIG: Required<RetryConfig> = {\n maxRetries: 3,\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n enableJitter: true,\n shouldRetry: (error: ClientApiError, attemptNumber: number) => {\n // Don't retry after max attempts\n if (attemptNumber >= 3) return false;\n\n // Always retry retryable errors\n if (error.isRetryable) return true;\n\n // Don't retry non-retryable errors\n return false;\n },\n onRetry: (error: ClientApiError, attemptNumber: number, delay: number) => {\n logger.warning(`Retrying HTTP request (attempt ${attemptNumber + 1}) after ${delay}ms`, {\n errorCode: error.code,\n errorMessage: error.message,\n delay,\n attemptNumber\n });\n }\n};\n\n/**\n * Sleep utility for retry delays\n */\nconst sleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms));\n\n/**\n * Calculate delay for exponential backoff with optional jitter\n */\nfunction calculateDelay(\n attemptNumber: number,\n config: Required<RetryConfig>\n): number {\n const exponentialDelay = config.initialDelayMs * Math.pow(config.backoffMultiplier, attemptNumber);\n const cappedDelay = Math.min(exponentialDelay, config.maxDelayMs);\n\n if (!config.enableJitter) {\n return cappedDelay;\n }\n\n // Add jitter: random value between 50% and 100% of calculated delay\n const jitter = 0.5 + (Math.random() * 0.5);\n return Math.floor(cappedDelay * jitter);\n}\n\n/**\n * Enhanced HTTP wrapper with retry logic and comprehensive error handling\n */\nexport class HttpWrapper {\n private readonly api: HttpApi;\n private readonly retryConfig: Required<RetryConfig>;\n\n constructor(api: HttpApi, retryConfig: RetryConfig = {}) {\n this.api = api;\n this.retryConfig = { ...DEFAULT_RETRY_CONFIG, ...retryConfig };\n }\n\n /**\n * Execute HTTP operation with retry logic and error handling\n */\n async executeWithRetry<T>(\n operation: () => Promise<T>,\n operationName: string,\n context?: Record<string, any>\n ): Promise<T> {\n let lastError: ClientApiError | null = null;\n const startTime = Date.now();\n\n for (let attempt = 0; attempt <= this.retryConfig.maxRetries; attempt++) {\n try {\n logger.debug(`Executing ${operationName}`, {\n attempt: attempt + 1,\n maxRetries: this.retryConfig.maxRetries + 1,\n ...context\n });\n\n const result = await operation();\n\n if (attempt > 0) {\n logger.info(`${operationName} succeeded after ${attempt} retries`, {\n totalAttempts: attempt + 1,\n duration: Date.now() - startTime,\n ...context\n });\n }\n\n return result;\n } catch (error) {\n lastError = this.convertToClientApiError(error, operationName, context);\n\n // Don't retry on the last attempt\n if (attempt === this.retryConfig.maxRetries) {\n break;\n }\n\n // Check if we should retry this error\n if (!this.retryConfig.shouldRetry(lastError, attempt)) {\n logger.debug(`Not retrying ${operationName} due to non-retryable error`, {\n errorCode: lastError.code,\n errorMessage: lastError.message,\n attempt: attempt + 1,\n ...context\n });\n break;\n }\n\n // Handle rate limiting with custom delay\n let delay = calculateDelay(attempt, this.retryConfig);\n if (lastError instanceof RateLimitError && lastError.retryAfter) {\n delay = Math.max(delay, lastError.retryAfter * 1000);\n }\n\n // Call retry callback\n this.retryConfig.onRetry(lastError, attempt, delay);\n\n // Wait before retrying\n await sleep(delay);\n }\n }\n\n // Log final failure\n logger.error(`${operationName} failed after ${this.retryConfig.maxRetries + 1} attempts`, {\n errorCode: lastError?.code,\n errorMessage: lastError?.message,\n duration: Date.now() - startTime,\n ...context\n });\n\n throw lastError;\n }\n\n /**\n * Convert any error to a ClientApiError\n */\n private convertToClientApiError(\n error: any,\n operationName: string,\n context?: Record<string, any>\n ): ClientApiError {\n const errorContext = { operation: operationName, ...context };\n\n // If it's already a ClientApiError, return as-is\n if (error instanceof ClientApiError) {\n return error;\n }\n\n // Handle HTTP response errors\n if (error.response) {\n const { status, statusText, data, headers } = error.response;\n return createHttpError(status, statusText, data, {\n ...errorContext,\n headers,\n url: error.config?.url\n });\n }\n\n // Handle request errors (network issues, timeouts, etc.)\n if (error.request) {\n return createNetworkError(error, {\n ...errorContext,\n url: error.config?.url,\n method: error.config?.method\n });\n }\n\n // Handle configuration or other errors\n return createNetworkError(error, errorContext);\n }\n\n /**\n * Wrapper for HTTP GET operations\n */\n async get<T>(\n url: string,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpGet(url, options),\n 'GET',\n { url, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP POST operations\n */\n async post<T>(\n url: string,\n data?: any,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpPost(url, data, options),\n 'POST',\n { url, hasData: !!data, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP PUT operations\n */\n async put<T>(\n url: string,\n data?: any,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpPut(url, data, options),\n 'PUT',\n { url, hasData: !!data, ...context }\n );\n }\n\n /**\n * Wrapper for HTTP DELETE operations\n */\n async delete<T>(\n url: string,\n options?: any,\n context?: Record<string, any>\n ): Promise<T> {\n return this.executeWithRetry(\n () => this.api.httpDelete(url, options),\n 'DELETE',\n { url, ...context }\n );\n }\n\n /**\n * Update retry configuration\n */\n updateRetryConfig(newConfig: Partial<RetryConfig>): void {\n Object.assign(this.retryConfig, newConfig);\n }\n\n /**\n * Get current retry configuration\n */\n getRetryConfig(): Required<RetryConfig> {\n return { ...this.retryConfig };\n }\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EAOE;AAAA,OACK;;;ACRP,OAAO,aAAa;AAEpB,IAAM,YAAY,QAAQ,UAAU,mBAAmB;AAEvD,IAAO,iBAAQ;;;ADWf,IAAM,SAAS,eAAU,IAAI,cAAc,OAAO,KAAK;AAEhD,IAAM,kBAAkB,CAQ3B,KACA,YACA,cAEwC;AAE1C,QAAM,MAAM,OACV,QAAmB,CAAC,GACpB,YAAkD,CAAC,GACnD,eACmC;AACnC,cAAU,gBAAgB,SAAS;AACnC,UAAM,MAA4C;AAGlD,UAAM,SAAsB,cAAc,KAAK;AAG/C,QAAI,cAAc,WAAW,cAAc,WAAW,SAAS,MAAM;AACnE,aAAO,QAAQ,OAAO,WAAW,KAAK;AAAA,IACxC;AACA,QAAI,cAAc,YAAY,cAAc,WAAW,UAAU,MAAM;AACrE,aAAO,SAAS,OAAO,WAAW,MAAM;AAAA,IAC1C;AAEA,UAAM,iBAAiB,OAAO,OAAO,CAAC,GAAG,WAAW,YAAY,EAAE,iBAAiB,WAAW,kBAAkB,OAAO,CAAC;AAExH,WAAO,QAAQ,OAAO,EAAE,OAAO,WAAW,YAAY,eAAe,CAAC;AACtE,WAAO,MAAM,sDAAsD;AAAA,MACjE,OAAO,KAAK,UAAU,KAAK;AAAA,MAC3B,WAAW,KAAK,UAAU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AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IACJ,KACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,QAAQ,KAAK,OAAO;AAAA,MACnC;AAAA,MACA,EAAE,KAAK,GAAG,QAAQ;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KACJ,KACA,MACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,SAAS,KAAK,MAAM,OAAO;AAAA,MAC1C;AAAA,MACA,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IACJ,KACA,MACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,QAAQ,KAAK,MAAM,OAAO;AAAA,MACzC;AAAA,MACA,EAAE,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OACJ,KACA,SACA,SACY;AACZ,WAAO,KAAK;AAAA,MACV,MAAM,KAAK,IAAI,WAAW,KAAK,OAAO;AAAA,MACtC;AAAA,MACA,EAAE,KAAK,GAAG,QAAQ;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,WAAuC;AACvD,WAAO,OAAO,KAAK,aAAa,SAAS;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAwC;AACtC,WAAO,EAAE,GAAG,KAAK,YAAY;AAAA,EAC/B;AACF;",
6
+ "names": ["logger", "action", "logger", "queryToParams", "logger", "queryToParams", "logger", "logger", "logger", "logger", "logger", "totalDuration", "logger", "logger", "logger", "logger", "facet", "logger", "logger", "logger", "logger", "logger", "ensureItemsExtracted", "action", "facet", "options", "logger", "logger", "logger", "isFjellHttpError", "logger"]
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fjell/client-api",
3
3
  "description": "Client API for Fjell",
4
- "version": "4.4.58",
4
+ "version": "4.4.60",
5
5
  "keywords": [
6
6
  "client",
7
7
  "api",
@@ -38,10 +38,10 @@
38
38
  "docs:test": "cd docs && npm run test"
39
39
  },
40
40
  "dependencies": {
41
- "@fjell/core": "^4.4.64",
42
- "@fjell/http-api": "^4.4.54",
41
+ "@fjell/core": "^4.4.66",
42
+ "@fjell/http-api": "^4.4.56",
43
43
  "@fjell/logging": "^4.4.59",
44
- "@fjell/registry": "^4.4.70",
44
+ "@fjell/registry": "^4.4.72",
45
45
  "deepmerge": "^4.3.1"
46
46
  },
47
47
  "devDependencies": {