@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.
- package/dist/client/api.d.ts +1 -9
- package/dist/client/api.js +3 -3
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.js +2 -2
- package/dist/client/types.d.ts +12 -0
- package/dist/client/types.js +5 -0
- package/dist/http/index.d.ts +2 -1
- package/dist/http/responses.d.ts +0 -7
- package/dist/http/types.d.ts +10 -0
- package/dist/http/types.js +5 -0
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +2 -2
- package/dist/storage/keys.d.ts +8 -0
- package/dist/storage/keys.js +14 -0
- package/package.json +1 -1
package/dist/client/api.d.ts
CHANGED
|
@@ -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
|
*/
|
package/dist/client/api.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.apiPut = apiPut;
|
|
|
8
8
|
exports.apiPatch = apiPatch;
|
|
9
9
|
exports.apiDelete = apiDelete;
|
|
10
10
|
exports.apiCallSafe = apiCallSafe;
|
|
11
|
-
const
|
|
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
|
|
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
|
|
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' };
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { ApiError } from './
|
|
2
|
-
export {
|
|
1
|
+
export { ApiError } from './apiError';
|
|
2
|
+
export { type ApiResponse } from './types';
|
|
3
|
+
export { initApiClient, apiCall, apiGet, apiPost, apiPut, apiPatch, apiDelete, apiCallSafe } from './api';
|
package/dist/client/index.js
CHANGED
|
@@ -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
|
|
5
|
-
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return
|
|
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; } });
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { HTTP_STATUS, type HttpStatus } from './status';
|
|
2
|
-
export { type ErrorResponse
|
|
2
|
+
export { type ErrorResponse } from './types';
|
|
3
|
+
export { badRequestResponse, unauthorizedResponse, forbiddenResponse, notFoundResponse, conflictResponse, handleFunctionError, isNotFoundError, isConflictError } from './responses';
|
package/dist/http/responses.d.ts
CHANGED
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initStorage, initStorageFromEnv, useManagedIdentity, getTableClient, clearTableClientCache } from './client';
|
|
2
|
-
export { generateRowKey } from './
|
|
2
|
+
export { generateRowKey } from './keys';
|
package/dist/storage/index.js
CHANGED
|
@@ -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
|
|
11
|
-
Object.defineProperty(exports, "generateRowKey", { enumerable: true, get: function () { return
|
|
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
|
+
}
|