@superbuilders/primer-tives 5.0.1 → 5.0.4

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/README.md CHANGED
@@ -19,7 +19,7 @@ bun add @superbuilders/primer-tives
19
19
 
20
20
  ## Version
21
21
 
22
- The current SDK version is `5.0.0`.
22
+ The current SDK version is `5.0.4`.
23
23
 
24
24
  ## Entrypoints
25
25
 
@@ -899,6 +899,10 @@ Fatal sentinels:
899
899
  | --- | --- |
900
900
  | `ErrBadRequest` | Primer rejected the runtime request as invalid for the SDK contract. |
901
901
  | `ErrCurriculumInstructionalUndeliverable` | The active curriculum instructional has no deliverable frame content. |
902
+ | `ErrNoActiveFrame` | Primer had no open frame for the submitted intent. |
903
+ | `ErrFrameAlreadyAnswered` | The targeted frame was already answered. |
904
+ | `ErrSessionStateConflict` | The learner intent does not match the active frame type. |
905
+ | `ErrNoRoutableContent` | The catalog has no routable bootstrap content for the learner's scope. |
902
906
  | `ErrInvalidAccessToken` | The learner token was rejected. |
903
907
  | `ErrTokenExpired` | The learner token expired. |
904
908
  | `ErrForbidden` | The learner is not allowed to continue in this runtime scope. |
@@ -1278,17 +1282,21 @@ import {
1278
1282
  ErrConflict,
1279
1283
  ErrCurriculumInstructionalUndeliverable,
1280
1284
  ErrForbidden,
1285
+ ErrFrameAlreadyAnswered,
1281
1286
  ErrInvalidAccessToken,
1282
1287
  ErrInvalidSubmission,
1283
1288
  ErrJsonParse,
1284
1289
  ErrMalformedAccessToken,
1285
1290
  ErrNetwork,
1291
+ ErrNoActiveFrame,
1292
+ ErrNoRoutableContent,
1286
1293
  ErrNotFound,
1287
1294
  ErrNotSerializable,
1288
1295
  ErrRateLimited,
1289
1296
  ErrSdkUpgradeRequired,
1290
1297
  ErrServerError,
1291
1298
  ErrServiceUnavailable,
1299
+ ErrSessionStateConflict,
1292
1300
  ErrTimeout,
1293
1301
  ErrTokenExpired,
1294
1302
  ErrUnsupportedPci
@@ -1325,6 +1333,10 @@ Runtime errors are represented as `ErroredState` or `FatalState`.
1325
1333
  | `ErrInvalidSubmission` | `ErroredState` | no | Renderer submitted a value that is invalid for the active interaction. |
1326
1334
  | `ErrBadRequest` | `FatalState` | no | Runtime request violates the SDK contract. |
1327
1335
  | `ErrCurriculumInstructionalUndeliverable` | `FatalState` | no | Curriculum routing reached an instructional with no deliverable frame content. |
1336
+ | `ErrNoActiveFrame` | `FatalState` | no | Primer had no open frame for the submitted intent. |
1337
+ | `ErrFrameAlreadyAnswered` | `FatalState` | no | The targeted frame was already answered. |
1338
+ | `ErrSessionStateConflict` | `FatalState` | no | The learner intent does not match the active frame type. |
1339
+ | `ErrNoRoutableContent` | `FatalState` | no | Catalog bootstrap has no routable content for the learner scope. |
1328
1340
  | `ErrInvalidAccessToken` | `FatalState` | no | Learner token is invalid. |
1329
1341
  | `ErrTokenExpired` | `FatalState` | no | Learner token expired. |
1330
1342
  | `ErrForbidden` | `FatalState` | no | Learner cannot continue in this runtime scope. |
@@ -6280,6 +6280,10 @@ var ErrAuthPopupBlocked = errors.new("auth popup blocked");
6280
6280
  var ErrAuthCancelled = errors.new("auth cancelled");
6281
6281
  var ErrSdkUpgradeRequired = errors.new("sdk upgrade required");
6282
6282
  var ErrCurriculumInstructionalUndeliverable = errors.new("curriculum instructional undeliverable");
6283
+ var ErrNoRoutableContent = errors.new("no routable content");
6284
+ var ErrNoActiveFrame = errors.new("no active frame");
6285
+ var ErrFrameAlreadyAnswered = errors.new("frame already answered");
6286
+ var ErrSessionStateConflict = errors.new("session state conflict");
6283
6287
  // src/contracts/content.ts
6284
6288
  function inlinesToPlainText(nodes) {
6285
6289
  const parts = [];
@@ -7757,6 +7761,10 @@ var FATAL_SENTINELS = [
7757
7761
  ErrTokenExpired,
7758
7762
  ErrForbidden,
7759
7763
  ErrNotFound,
7764
+ ErrNoActiveFrame,
7765
+ ErrNoRoutableContent,
7766
+ ErrFrameAlreadyAnswered,
7767
+ ErrSessionStateConflict,
7760
7768
  ErrSdkUpgradeRequired,
7761
7769
  ErrUnsupportedPci
7762
7770
  ];
@@ -7815,7 +7823,6 @@ function makeSession(sc) {
7815
7823
  }
7816
7824
  }
7817
7825
  function errored(error, failedPhase, intent) {
7818
- let pending;
7819
7826
  const retriable = isRetriableError(error);
7820
7827
  if (!retriable) {
7821
7828
  return {
@@ -7825,6 +7832,7 @@ function makeSession(sc) {
7825
7832
  toJSON: poisonToJSON
7826
7833
  };
7827
7834
  }
7835
+ let pending;
7828
7836
  const state = {
7829
7837
  phase: "errored",
7830
7838
  error,
@@ -7948,7 +7956,7 @@ function makeSession(sc) {
7948
7956
  import * as errors12 from "@superbuilders/errors";
7949
7957
 
7950
7958
  // src/version.ts
7951
- var SDK_VERSION = "5.0.0";
7959
+ var SDK_VERSION = "5.0.4";
7952
7960
  var NPM_PACKAGE_URL = "https://www.npmjs.com/package/@superbuilders/primer-tives";
7953
7961
 
7954
7962
  // src/client/transport.ts
@@ -8000,40 +8008,61 @@ function parseAdvanceErrorBody(body) {
8000
8008
  }
8001
8009
  return result;
8002
8010
  }
8003
- function httpSentinel(status, body) {
8004
- if (status === 400) {
8005
- const parsed = parseAdvanceErrorBody(body);
8006
- if (parsed?.error === "sdk_upgrade_required") {
8007
- return ErrSdkUpgradeRequired;
8008
- }
8009
- if (parsed?.error === "curriculum_instructional_undeliverable") {
8010
- return ErrCurriculumInstructionalUndeliverable;
8011
- }
8012
- return ErrBadRequest;
8013
- }
8014
- if (status === 401) {
8015
- const parsed = parseAdvanceErrorBody(body);
8016
- if (parsed?.detail === "token_expired") {
8017
- return ErrTokenExpired;
8011
+ var ADVANCE_400_ERRORS = {
8012
+ sdk_upgrade_required: ErrSdkUpgradeRequired,
8013
+ curriculum_instructional_undeliverable: ErrCurriculumInstructionalUndeliverable,
8014
+ no_routable_content: ErrNoRoutableContent
8015
+ };
8016
+ var ADVANCE_409_ERRORS = {
8017
+ no_active_frame: ErrNoActiveFrame,
8018
+ frame_already_answered: ErrFrameAlreadyAnswered,
8019
+ session_state_conflict: ErrSessionStateConflict
8020
+ };
8021
+ function advanceErrorSentinel(errorCode, mapping, fallback) {
8022
+ if (errorCode !== undefined) {
8023
+ const sentinel = mapping[errorCode];
8024
+ if (sentinel !== undefined) {
8025
+ return sentinel;
8018
8026
  }
8019
- return ErrInvalidAccessToken;
8020
8027
  }
8021
- if (status === 403) {
8022
- return ErrForbidden;
8023
- }
8024
- if (status === 404) {
8025
- return ErrNotFound;
8026
- }
8027
- if (status === 409) {
8028
- return ErrConflict;
8029
- }
8030
- if (status === 429) {
8031
- return ErrRateLimited;
8028
+ return fallback;
8029
+ }
8030
+ function badRequestSentinel(body) {
8031
+ const parsed = parseAdvanceErrorBody(body);
8032
+ return advanceErrorSentinel(parsed?.error, ADVANCE_400_ERRORS, ErrBadRequest);
8033
+ }
8034
+ function unauthorizedSentinel(body) {
8035
+ const parsed = parseAdvanceErrorBody(body);
8036
+ if (parsed?.detail === "token_expired") {
8037
+ return ErrTokenExpired;
8032
8038
  }
8033
- if (status === 502 || status === 503 || status === 504) {
8034
- return ErrServiceUnavailable;
8039
+ return ErrInvalidAccessToken;
8040
+ }
8041
+ function conflictSentinel(body) {
8042
+ const parsed = parseAdvanceErrorBody(body);
8043
+ return advanceErrorSentinel(parsed?.error, ADVANCE_409_ERRORS, ErrConflict);
8044
+ }
8045
+ function httpSentinel(status, body) {
8046
+ switch (status) {
8047
+ case 400:
8048
+ return badRequestSentinel(body);
8049
+ case 401:
8050
+ return unauthorizedSentinel(body);
8051
+ case 403:
8052
+ return ErrForbidden;
8053
+ case 404:
8054
+ return ErrNotFound;
8055
+ case 409:
8056
+ return conflictSentinel(body);
8057
+ case 429:
8058
+ return ErrRateLimited;
8059
+ case 502:
8060
+ case 503:
8061
+ case 504:
8062
+ return ErrServiceUnavailable;
8063
+ default:
8064
+ return ErrServerError;
8035
8065
  }
8036
- return ErrServerError;
8037
8066
  }
8038
8067
  function buildSdkUpgradeRequiredError(sentinel, text, logger) {
8039
8068
  const parsed = parseAdvanceErrorBody(text);
@@ -8274,4 +8303,4 @@ export {
8274
8303
  start
8275
8304
  };
8276
8305
 
8277
- //# debugId=5F7821132D289BDA64756E2164756E21
8306
+ //# debugId=B9AA7CC48F32D77C64756E2164756E21