@cronvello/shop-sdk 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.cjs CHANGED
@@ -5388,7 +5388,7 @@ function createShopClient(options = {}) {
5388
5388
  var CONTRACT_SHA256 = "32f132210ee188c28a330c9db5c6db6eaf5b7c3a65ecc041e029aca6e1335a60";
5389
5389
 
5390
5390
  // src/client/diagnose.ts
5391
- var SDK_VERSION = "0.2.3" ;
5391
+ var SDK_VERSION = "0.3.0" ;
5392
5392
  async function resolveBaseUrl(options) {
5393
5393
  const provider = options.client?.baseUrl ?? options.baseUrl ?? SHOP_API_URL;
5394
5394
  const value = typeof provider === "function" ? await provider() : provider;
package/dist/browser.js CHANGED
@@ -5386,7 +5386,7 @@ function createShopClient(options = {}) {
5386
5386
  var CONTRACT_SHA256 = "32f132210ee188c28a330c9db5c6db6eaf5b7c3a65ecc041e029aca6e1335a60";
5387
5387
 
5388
5388
  // src/client/diagnose.ts
5389
- var SDK_VERSION = "0.2.3" ;
5389
+ var SDK_VERSION = "0.3.0" ;
5390
5390
  async function resolveBaseUrl(options) {
5391
5391
  const provider = options.client?.baseUrl ?? options.baseUrl ?? SHOP_API_URL;
5392
5392
  const value = typeof provider === "function" ? await provider() : provider;
package/dist/index.cjs CHANGED
@@ -5737,7 +5737,7 @@ function createShopClient(options = {}) {
5737
5737
  var CONTRACT_SHA256 = "32f132210ee188c28a330c9db5c6db6eaf5b7c3a65ecc041e029aca6e1335a60";
5738
5738
 
5739
5739
  // src/client/diagnose.ts
5740
- var SDK_VERSION = "0.2.3" ;
5740
+ var SDK_VERSION = "0.3.0" ;
5741
5741
  async function resolveBaseUrl(options) {
5742
5742
  const provider = options.client?.baseUrl ?? options.baseUrl ?? SHOP_API_URL;
5743
5743
  const value = typeof provider === "function" ? await provider() : provider;
@@ -5829,6 +5829,104 @@ async function diagnoseShop(options = {}) {
5829
5829
  };
5830
5830
  }
5831
5831
 
5832
+ // src/capabilities.ts
5833
+ var SDK_VERSION2 = "0.3.0" ;
5834
+ var ROUTES = apiRoutes;
5835
+ var CLIENT_MANAGEMENT_OPS = [
5836
+ "external_apps_service_register",
5837
+ "external_apps_service_update",
5838
+ "external_apps_service_delete"
5839
+ ];
5840
+ var CLIENT_ROTATION_OPS = ["external_apps_service_rotate_key"];
5841
+ var PEER_STATUS_OPS = ["external_apps_service_status"];
5842
+ function has(operationId) {
5843
+ return Object.prototype.hasOwnProperty.call(ROUTES, operationId);
5844
+ }
5845
+ function capabilityFrom(operationIds, reasonWhenMissing) {
5846
+ const present = operationIds.filter(has);
5847
+ if (present.length === operationIds.length) {
5848
+ return { supported: true, operations: present };
5849
+ }
5850
+ const missing = operationIds.filter((id) => !present.includes(id));
5851
+ return {
5852
+ supported: false,
5853
+ operations: present,
5854
+ reason: `${reasonWhenMissing} Fehlend im Vertrag: ${missing.join(", ")}.`
5855
+ };
5856
+ }
5857
+ function capabilityFromPrefix(prefix, reasonWhenMissing) {
5858
+ const present = Object.keys(ROUTES).filter((id) => id.startsWith(prefix));
5859
+ return present.length > 0 ? { supported: true, operations: present } : { supported: false, operations: [], reason: reasonWhenMissing };
5860
+ }
5861
+ function shopCapabilities() {
5862
+ const operationIds = Object.keys(ROUTES);
5863
+ const authChannels = {};
5864
+ for (const id of operationIds) {
5865
+ const channel = ROUTES[id]?.auth?.type ?? "none";
5866
+ authChannels[channel] = (authChannels[channel] ?? 0) + 1;
5867
+ }
5868
+ return {
5869
+ service: "node-shop",
5870
+ sdkVersion: SDK_VERSION2,
5871
+ contractSha256: CONTRACT_SHA256,
5872
+ operationCount: operationIds.length,
5873
+ authChannels,
5874
+ capabilities: {
5875
+ // Der Endpunkt beschreibt den Vertrag und kann deshalb nicht in ihm stehen. Er
5876
+ // gehoert zur Zusage dieses SDK und wird von `diagnoseShop` live geprueft.
5877
+ contractFingerprint: { supported: true, operations: [] },
5878
+ healthCheck: capabilityFrom(
5879
+ ["app_info_health"],
5880
+ "Ohne Erreichbarkeits-Endpunkt bleibt nur der Umweg ueber eine echte Anfrage."
5881
+ ),
5882
+ clientManagement: capabilityFrom(
5883
+ CLIENT_MANAGEMENT_OPS,
5884
+ "Ohne diese Routen kann ein Verwalter keine Anbindung fuer andere Apps einrichten."
5885
+ ),
5886
+ clientRotation: capabilityFrom(
5887
+ CLIENT_ROTATION_OPS,
5888
+ "Ohne Erneuerung ist ein einmal ausgegebener Schluessel dauerhaft."
5889
+ ),
5890
+ // Anders als bei orvello haengt die Gnadenfrist nicht an eigenen Routen, sondern am
5891
+ // Feld `gracePeriodHours` derselben Rotation: der alte Schluessel bleibt so lange
5892
+ // gueltig und laeuft dann von selbst ab. Das ist eine Zusage des Vertrags, aber
5893
+ // keine, die sich anhand einer Operation belegen laesst — deshalb steht als Beleg
5894
+ // die Rotation selbst und nicht eine erfundene zweite Operation.
5895
+ rotationGracePeriod: has("external_apps_service_rotate_key") ? { supported: true, operations: CLIENT_ROTATION_OPS } : {
5896
+ supported: false,
5897
+ operations: [],
5898
+ reason: "Ohne Rotation gibt es auch keine Gnadenfrist."
5899
+ },
5900
+ clientRevocation: {
5901
+ supported: false,
5902
+ operations: [],
5903
+ reason: "node-shop kennt keinen eigenen Widerruf. Ein Zugang wird entzogen, indem die App auf `isActive: false` gesetzt (external_apps_service_update) oder geloescht wird (external_apps_service_delete) \u2014 das erste ist reversibel, das zweite endgueltig. Ein Verwalter, der nur den Schluessel ungueltig machen will, ohne die Anbindung anzufassen, hat dafuer heute keine Operation."
5904
+ },
5905
+ peerStatus: capabilityFrom(
5906
+ PEER_STATUS_OPS,
5907
+ "Ohne Statusroute kann ein Verwalter nur raten, was der Shop ueber die App fuehrt."
5908
+ ),
5909
+ entitlements: capabilityFromPrefix(
5910
+ "entitlements_",
5911
+ "Dieser Vertrag kennt keine Berechtigungs-Routen."
5912
+ ),
5913
+ commerce: capabilityFromPrefix(
5914
+ "b2b_",
5915
+ "Dieser Vertrag kennt keine B2B-Routen \u2014 fremde Apps koennen darueber nichts verkaufen."
5916
+ ),
5917
+ usageMetering: capabilityFromPrefix(
5918
+ "usage_reports_",
5919
+ "Dieser Vertrag kennt keine Verbrauchs-Routen."
5920
+ ),
5921
+ serverSideDryRun: {
5922
+ supported: false,
5923
+ operations: [],
5924
+ reason: "node-shop bietet keinen serverseitigen Probelauf an. Nebenwirkungsfrei pruefbar ist der Weg trotzdem: `diagnoseShop` beweist Erreichbarkeit und Vertrag ohne zu schreiben, und `external_apps_service_status` beweist, was der Shop ueber die App fuehrt \u2014 beides beweist die Voraussetzung, nicht das Ergebnis."
5925
+ }
5926
+ }
5927
+ };
5928
+ }
5929
+
5832
5930
  exports.CONTRACT_SHA256 = CONTRACT_SHA256;
5833
5931
  exports.SHOP_API_URL = SHOP_API_URL;
5834
5932
  exports.ShopApiError = ShopApiError;
@@ -5885,5 +5983,6 @@ exports.apiRoutes_variant_entitlements = apiRoutes_variant_entitlements;
5885
5983
  exports.apiRoutes_webhooks = apiRoutes_webhooks;
5886
5984
  exports.createShopClient = createShopClient;
5887
5985
  exports.diagnoseShop = diagnoseShop;
5986
+ exports.shopCapabilities = shopCapabilities;
5888
5987
  //# sourceMappingURL=index.cjs.map
5889
5988
  //# sourceMappingURL=index.cjs.map