@markwharton/pwa-core 1.0.0 → 1.0.1

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.
@@ -1,3 +1,4 @@
1
+ import { ApiResponse } from './types';
1
2
  /**
2
3
  * Initialize the API client
3
4
  */
@@ -5,15 +6,6 @@ export declare function initApiClient(config: {
5
6
  getToken: () => string | null;
6
7
  onUnauthorized?: () => void;
7
8
  }): void;
8
- /**
9
- * API response wrapper
10
- */
11
- export interface ApiResponse<T> {
12
- ok: boolean;
13
- status: number;
14
- data?: T;
15
- error?: string;
16
- }
17
9
  /**
18
10
  * Make an authenticated API call
19
11
  */
@@ -8,7 +8,7 @@ exports.apiPut = apiPut;
8
8
  exports.apiPatch = apiPatch;
9
9
  exports.apiDelete = apiDelete;
10
10
  exports.apiCallSafe = apiCallSafe;
11
- const ApiError_1 = require("./ApiError");
11
+ const apiError_1 = require("./apiError");
12
12
  /**
13
13
  * Client-side API utilities for authenticated requests
14
14
  */
@@ -51,7 +51,7 @@ async function apiCall(url, options = {}) {
51
51
  catch {
52
52
  // Ignore JSON parse errors
53
53
  }
54
- throw new ApiError_1.ApiError(response.status, errorMessage);
54
+ throw new apiError_1.ApiError(response.status, errorMessage);
55
55
  }
56
56
  // Handle empty responses
57
57
  const text = await response.text();
@@ -108,7 +108,7 @@ async function apiCallSafe(url, options = {}) {
108
108
  return { ok: true, status: 200, data };
109
109
  }
110
110
  catch (error) {
111
- if (error instanceof ApiError_1.ApiError) {
111
+ if (error instanceof apiError_1.ApiError) {
112
112
  return { ok: false, status: error.status, error: error.message };
113
113
  }
114
114
  return { ok: false, status: 0, error: 'Network error' };
@@ -1,2 +1,3 @@
1
- export { ApiError } from './ApiError';
2
- export { initApiClient, type ApiResponse, apiCall, apiGet, apiPost, apiPut, apiPatch, apiDelete, apiCallSafe } from './api';
1
+ export { ApiError } from './apiError';
2
+ export { type ApiResponse } from './types';
3
+ export { initApiClient, apiCall, apiGet, apiPost, apiPut, apiPatch, apiDelete, apiCallSafe } from './api';
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiCallSafe = exports.apiDelete = exports.apiPatch = exports.apiPut = exports.apiPost = exports.apiGet = exports.apiCall = exports.initApiClient = exports.ApiError = void 0;
4
- var ApiError_1 = require("./ApiError");
5
- Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return ApiError_1.ApiError; } });
4
+ var apiError_1 = require("./apiError");
5
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return apiError_1.ApiError; } });
6
6
  var api_1 = require("./api");
7
7
  Object.defineProperty(exports, "initApiClient", { enumerable: true, get: function () { return api_1.initApiClient; } });
8
8
  Object.defineProperty(exports, "apiCall", { enumerable: true, get: function () { return api_1.apiCall; } });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Client module type definitions
3
+ */
4
+ /**
5
+ * API response wrapper for safe calls
6
+ */
7
+ export interface ApiResponse<T> {
8
+ ok: boolean;
9
+ status: number;
10
+ data?: T;
11
+ error?: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Client module type definitions
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export { HTTP_STATUS, type HttpStatus } from './status';
2
- export { type ErrorResponse, badRequestResponse, unauthorizedResponse, forbiddenResponse, notFoundResponse, conflictResponse, handleFunctionError, isNotFoundError, isConflictError } from './responses';
2
+ export { type ErrorResponse } from './types';
3
+ export { badRequestResponse, unauthorizedResponse, forbiddenResponse, notFoundResponse, conflictResponse, handleFunctionError, isNotFoundError, isConflictError } from './responses';
@@ -1,11 +1,4 @@
1
1
  import { HttpResponseInit, InvocationContext } from '@azure/functions';
2
- /**
3
- * Standard error response structure
4
- */
5
- export interface ErrorResponse {
6
- error: string;
7
- details?: string;
8
- }
9
2
  /**
10
3
  * Create a 400 Bad Request response
11
4
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * HTTP module type definitions
3
+ */
4
+ /**
5
+ * Standard error response structure
6
+ */
7
+ export interface ErrorResponse {
8
+ error: string;
9
+ details?: string;
10
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP module type definitions
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,2 @@
1
1
  export { initStorage, initStorageFromEnv, useManagedIdentity, getTableClient, clearTableClientCache } from './client';
2
- export { generateRowKey } from './helpers';
2
+ export { generateRowKey } from './keys';
@@ -7,5 +7,5 @@ Object.defineProperty(exports, "initStorageFromEnv", { enumerable: true, get: fu
7
7
  Object.defineProperty(exports, "useManagedIdentity", { enumerable: true, get: function () { return client_1.useManagedIdentity; } });
8
8
  Object.defineProperty(exports, "getTableClient", { enumerable: true, get: function () { return client_1.getTableClient; } });
9
9
  Object.defineProperty(exports, "clearTableClientCache", { enumerable: true, get: function () { return client_1.clearTableClientCache; } });
10
- var helpers_1 = require("./helpers");
11
- Object.defineProperty(exports, "generateRowKey", { enumerable: true, get: function () { return helpers_1.generateRowKey; } });
10
+ var keys_1 = require("./keys");
11
+ Object.defineProperty(exports, "generateRowKey", { enumerable: true, get: function () { return keys_1.generateRowKey; } });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generate a unique row key from an identifier string
3
+ * Uses SHA-256 hash for consistent, URL-safe keys
4
+ *
5
+ * @param identifier - The string to hash (e.g., subscription endpoint, user ID)
6
+ * @returns A 32-character hex string suitable for Azure Table Storage row keys
7
+ */
8
+ export declare function generateRowKey(identifier: string): string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateRowKey = generateRowKey;
4
+ const crypto_1 = require("crypto");
5
+ /**
6
+ * Generate a unique row key from an identifier string
7
+ * Uses SHA-256 hash for consistent, URL-safe keys
8
+ *
9
+ * @param identifier - The string to hash (e.g., subscription endpoint, user ID)
10
+ * @returns A 32-character hex string suitable for Azure Table Storage row keys
11
+ */
12
+ function generateRowKey(identifier) {
13
+ return (0, crypto_1.createHash)('sha256').update(identifier).digest('hex').substring(0, 32);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markwharton/pwa-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared patterns for Azure PWA projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",