@flytedesk/app-kit 16.1.0 → 16.2.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.
Files changed (34) hide show
  1. package/README.md +106 -0
  2. package/dist/chat/owed-replies/constants.d.ts +25 -0
  3. package/dist/chat/owed-replies/constants.js +45 -0
  4. package/dist/chat/owed-replies/constants.js.map +1 -0
  5. package/dist/chat/owed-replies/index.d.ts +15 -0
  6. package/dist/chat/owed-replies/index.js +12 -0
  7. package/dist/chat/owed-replies/index.js.map +1 -0
  8. package/dist/chat/owed-replies/plugin.d.ts +31 -0
  9. package/dist/chat/owed-replies/plugin.js +25 -0
  10. package/dist/chat/owed-replies/plugin.js.map +1 -0
  11. package/dist/chat/owed-replies/state.d.ts +46 -0
  12. package/dist/chat/owed-replies/state.js +31 -0
  13. package/dist/chat/owed-replies/state.js.map +1 -0
  14. package/dist/chat/owed-replies/store.d.ts +57 -0
  15. package/dist/chat/owed-replies/store.js +178 -0
  16. package/dist/chat/owed-replies/store.js.map +1 -0
  17. package/dist/chat/owed-replies/tool.d.ts +12 -0
  18. package/dist/chat/owed-replies/tool.js +61 -0
  19. package/dist/chat/owed-replies/tool.js.map +1 -0
  20. package/dist/chat/tools/index.d.ts +13 -0
  21. package/dist/chat/tools/index.js +18 -2
  22. package/dist/chat/tools/index.js.map +1 -1
  23. package/dist/cli/owed-reply-sync.d.ts +2 -0
  24. package/dist/cli/owed-reply-sync.js +28 -0
  25. package/dist/cli/owed-reply-sync.js.map +1 -0
  26. package/dist/flytebot/testing/fake.d.ts +33 -4
  27. package/dist/flytebot/testing/fake.js +100 -3
  28. package/dist/flytebot/testing/fake.js.map +1 -1
  29. package/dist/flytebot/testing/index.d.ts +1 -1
  30. package/package.json +8 -3
  31. package/prisma/fragments/owed-reply.meta.json +4 -0
  32. package/prisma/fragments/owed-reply.prisma +52 -0
  33. package/prisma/migrations/0006_app_kit_owed_reply_init/migration.sql +63 -0
  34. package/prisma/migrations/manifest.json +7 -0
@@ -0,0 +1,63 @@
1
+ -- @flytedesk/app-kit/chat/owed-replies :: 0006_app_kit_owed_reply_init
2
+ --
3
+ -- The tables behind the owed-reply store: one row per message of a person that is owed an
4
+ -- answer, and the run that took it. Column names, types and defaults match
5
+ -- prisma/fragments/owed-reply.prisma (Prisma's own mapping: TEXT, INTEGER, TIMESTAMP(3)),
6
+ -- then the CHECK constraints Prisma's schema language cannot express. One DO block, so the
7
+ -- tables, indexes and checks apply together or not at all. For an app that does not use
8
+ -- Prisma migrate; an app that does writes its own migration from the fragment, and
9
+ -- `owed-reply-sync` prints the CHECK lines below for it to append (see sync-engine.ts).
10
+
11
+ DO $owed_reply$
12
+ BEGIN
13
+ SET LOCAL lock_timeout = '5s';
14
+
15
+ -- CreateTable
16
+ CREATE TABLE "app_kit_owed_reply" (
17
+ "id" TEXT NOT NULL,
18
+ "message_ref" TEXT NOT NULL,
19
+ "conversation_ref" TEXT NOT NULL,
20
+ "person_ref" TEXT NOT NULL,
21
+ "ack_text" TEXT,
22
+ "reply_text" TEXT,
23
+ "failure" TEXT,
24
+ "revision" INTEGER NOT NULL DEFAULT 0,
25
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
26
+ "acked_at" TIMESTAMP(3),
27
+ "answered_at" TIMESTAMP(3),
28
+ "failed_at" TIMESTAMP(3),
29
+
30
+ CONSTRAINT "app_kit_owed_reply_pkey" PRIMARY KEY ("id")
31
+ );
32
+
33
+ -- CreateTable
34
+ CREATE TABLE "app_kit_owed_reply_dispatch" (
35
+ "owed_reply_id" TEXT NOT NULL,
36
+ "dispatch_id" TEXT NOT NULL,
37
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
38
+
39
+ CONSTRAINT "app_kit_owed_reply_dispatch_pkey" PRIMARY KEY ("owed_reply_id","dispatch_id")
40
+ );
41
+
42
+ -- CreateIndex
43
+ CREATE UNIQUE INDEX "app_kit_owed_reply_message_ref_key" ON "app_kit_owed_reply"("message_ref");
44
+
45
+ -- CreateIndex
46
+ CREATE INDEX "app_kit_owed_reply_conversation_ref_idx" ON "app_kit_owed_reply"("conversation_ref");
47
+
48
+ -- CreateIndex
49
+ CREATE INDEX "app_kit_owed_reply_dispatch_dispatch_id_idx" ON "app_kit_owed_reply_dispatch"("dispatch_id");
50
+
51
+ -- AddCheck: an acknowledgement, a reply and a failure each carry the time they were written, and never one without the other.
52
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_ack_complete" CHECK (("ack_text" IS NULL) = ("acked_at" IS NULL));
53
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_answer_complete" CHECK (("reply_text" IS NULL) = ("answered_at" IS NULL));
54
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_failure_complete" CHECK (("failure" IS NULL) = ("failed_at" IS NULL));
55
+
56
+ -- AddCheck: an owed reply is answered or failed, never both, and none of its texts is blank.
57
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_settled_once" CHECK ("reply_text" IS NULL OR "failure" IS NULL);
58
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_text_not_blank" CHECK (("ack_text" IS NULL OR btrim("ack_text") <> '') AND ("reply_text" IS NULL OR btrim("reply_text") <> '') AND ("failure" IS NULL OR btrim("failure") <> ''));
59
+
60
+ -- AddCheck: the revision only ever counts up from zero.
61
+ ALTER TABLE "app_kit_owed_reply" ADD CONSTRAINT "app_kit_owed_reply_revision_valid" CHECK ("revision" >= 0);
62
+ END
63
+ $owed_reply$;
@@ -33,5 +33,12 @@
33
33
  "file": "0005_app_kit_signed_in_person/migration.sql",
34
34
  "checksum": "sha256:1504c518ac0a0818a327cb4acc639373218896c115f604e25f605af42e0910bd",
35
35
  "introducedInFragmentVersion": "1.1.0"
36
+ },
37
+ {
38
+ "id": "0006_app_kit_owed_reply_init",
39
+ "fragment": "owed-reply",
40
+ "file": "0006_app_kit_owed_reply_init/migration.sql",
41
+ "checksum": "sha256:7e066dfa5a82cf212ac915a7861476ee6a67967ad94a1f1462480c9d4689a4aa",
42
+ "introducedInFragmentVersion": "1.0.0"
36
43
  }
37
44
  ]