@composable-os/pack-shop 0.0.0-stage → 0.1.0-beta.13

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/LICENSE ADDED
@@ -0,0 +1,109 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ > This licence covers the repository except the directories listed in NOTICE. In particular, the
4
+ > assistant packages `packages/agent-*` (agent-core, agent-a2ui, agent-voice, agent-plugins) are
5
+ > licensed under the MIT License; see the LICENSE file in each of those directories (ADR 0350).
6
+
7
+ ## Abbreviation
8
+
9
+ FSL-1.1-ALv2
10
+
11
+ ## Notice
12
+
13
+ Copyright 2026 Tim O'Connell
14
+
15
+ ## Terms and Conditions
16
+
17
+ ### Licensor ("We")
18
+
19
+ The party offering the Software under these Terms and Conditions.
20
+
21
+ ### The Software
22
+
23
+ The "Software" is each version of the software that we make available under
24
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
25
+ Conditions with the Software.
26
+
27
+ ### License Grant
28
+
29
+ Subject to your compliance with this License Grant and the Patents,
30
+ Redistribution and Trademark clauses below, we hereby grant you the right to
31
+ use, copy, modify, create derivative works, publicly perform, publicly display
32
+ and redistribute the Software for any Permitted Purpose identified below.
33
+
34
+ ### Permitted Purpose
35
+
36
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
37
+ means making the Software available to others in a commercial product or
38
+ service that:
39
+
40
+ 1. substitutes for the Software;
41
+
42
+ 2. substitutes for any other product or service we offer using the Software
43
+ that exists as of the date we make the Software available; or
44
+
45
+ 3. offers the same or substantially similar functionality as the Software.
46
+
47
+ Permitted Purposes specifically include using the Software:
48
+
49
+ 1. for your internal use and access;
50
+
51
+ 2. for non-commercial education;
52
+
53
+ 3. for non-commercial research; and
54
+
55
+ 4. in connection with professional services that you provide to a licensee
56
+ using the Software in accordance with these Terms and Conditions.
57
+
58
+ ### Patents
59
+
60
+ To the extent your use for a Permitted Purpose would necessarily infringe our
61
+ patents, the license grant above includes a license under our patents. If you
62
+ make a claim against any party that the Software infringes or contributes to
63
+ the infringement of any patent, then your patent license to the Software ends
64
+ immediately.
65
+
66
+ ### Redistribution
67
+
68
+ The Terms and Conditions apply to all copies, modifications and derivatives of
69
+ the Software.
70
+
71
+ If you redistribute any copies, modifications or derivatives of the Software,
72
+ you must include a copy of or a link to these Terms and Conditions and not
73
+ remove any copyright notices provided in or with the Software.
74
+
75
+ ### Disclaimer
76
+
77
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
78
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
79
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
80
+
81
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
82
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
83
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
84
+
85
+ ### Trademarks
86
+
87
+ Except for displaying the License Details and identifying us as the origin of
88
+ the Software, you have no right under these Terms and Conditions to use our
89
+ trademarks, trade names, service marks or product names.
90
+
91
+ ## Grant of Future License
92
+
93
+ We hereby irrevocably grant you an additional license to use the Software under
94
+ the Apache License, Version 2.0 that is effective on the second anniversary of
95
+ the date we make the Software available. On or after that date, you may use the
96
+ Software under the Apache License, Version 2.0, in which case the following
97
+ will apply:
98
+
99
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
100
+ this file except in compliance with the License.
101
+
102
+ You may obtain a copy of the License at
103
+
104
+ http://www.apache.org/licenses/LICENSE-2.0
105
+
106
+ Unless required by applicable law or agreed to in writing, software distributed
107
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
108
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
109
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1,5 @@
1
+ import type { DashboardDeclaration } from "@composable-os/sdk";
2
+ export declare const shopOverview: DashboardDeclaration;
3
+ export declare const shopDashboards: {
4
+ shopOverview: DashboardDeclaration;
5
+ };
@@ -0,0 +1,97 @@
1
+ const LOW = "v.state = 'active' AND v.reorder_at IS NOT NULL AND v._stk_on_hand <= v.reorder_at";
2
+ const SOLD = `FROM rec_order_line l JOIN rec_order o ON o.id = l.order_id
3
+ JOIN rec_x_shop_variant v ON v.id = l.record_id
4
+ LEFT JOIN rec_x_shop_item i ON i.id = v.item
5
+ WHERE l.object_type = 'shop.variant' AND o.state = 'paid'
6
+ AND o.paid_at >= :paid_from AND o.paid_at < :paid_to`;
7
+ export const shopOverview = {
8
+ title: "Shop",
9
+ description: "What is low and who supplies it, what is waiting to be packed or collected, and what sold.",
10
+ filters: [{ type: "dateRange", id: "paid", label: "Paid", default: "this_month" }],
11
+ widgets: [
12
+ {
13
+ id: "low",
14
+ type: "kpi",
15
+ title: "Low on stock",
16
+ description: "Active variants with on hand at or below their reorder level.",
17
+ sql: `SELECT count(*) AS value FROM rec_x_shop_variant v WHERE ${LOW}`,
18
+ mapping: { value: "value" },
19
+ options: { compare: false },
20
+ layout: { w: 3, h: 1 },
21
+ },
22
+ {
23
+ id: "to-pack",
24
+ type: "kpi",
25
+ title: "To pack",
26
+ description: "Shipments of paid orders not yet packed.",
27
+ sql: "SELECT count(*) AS value FROM rec_x_shop_shipment s WHERE s.state = 'to_pack'",
28
+ mapping: { value: "value" },
29
+ options: { compare: false },
30
+ clickThrough: {
31
+ object: "shop.shipment",
32
+ filter: { field: "state", op: "eq", value: "to_pack" },
33
+ },
34
+ layout: { w: 3, h: 1 },
35
+ },
36
+ {
37
+ id: "ready",
38
+ type: "kpi",
39
+ title: "Ready to collect",
40
+ description: "Shipments waiting for their buyer to collect them.",
41
+ sql: "SELECT count(*) AS value FROM rec_x_shop_shipment s WHERE s.state = 'ready'",
42
+ mapping: { value: "value" },
43
+ options: { compare: false },
44
+ clickThrough: {
45
+ object: "shop.shipment",
46
+ filter: { field: "state", op: "eq", value: "ready" },
47
+ },
48
+ layout: { w: 3, h: 1 },
49
+ },
50
+ {
51
+ id: "sales",
52
+ type: "kpi",
53
+ title: "Shop sales",
54
+ description: "Line totals of shop goods on orders paid in the period (postage left out).",
55
+ sql: `SELECT coalesce(sum(l.line_total), 0) / 100.0 AS value ${SOLD}`,
56
+ mapping: { value: "value" },
57
+ options: { compare: true, format: "currency" },
58
+ layout: { w: 3, h: 1 },
59
+ },
60
+ {
61
+ id: "low-by-supplier",
62
+ type: "table",
63
+ title: "Low stock by supplier",
64
+ description: "Each active variant at or below its reorder level, its usual supplier and how many to " +
65
+ "order: ready to become a purchase order.",
66
+ sql: `SELECT v.id AS id, coalesce(o.name, 'No supplier') AS supplier, v.name AS variant,
67
+ v._stk_on_hand AS on_hand, v._stk_held AS held, v.reorder_at AS reorder_at,
68
+ v.reorder_qty AS reorder_qty
69
+ FROM rec_x_shop_variant v LEFT JOIN rec_organisation o ON o.id = v.supplier
70
+ WHERE ${LOW}
71
+ ORDER BY supplier, v._stk_on_hand LIMIT 100`,
72
+ mapping: {
73
+ columns: ["supplier", "variant", "on_hand", "held", "reorder_at", "reorder_qty"],
74
+ },
75
+ clickThrough: {
76
+ object: "shop.variant",
77
+ filter: { field: "id", op: "eq", value: { $row: "id" } },
78
+ },
79
+ layout: { w: 12, h: 2 },
80
+ },
81
+ {
82
+ id: "best-sellers",
83
+ type: "bar",
84
+ title: "Sold by item",
85
+ description: "Units of each item sold on orders paid in the period.",
86
+ sql: `SELECT i.id AS item_id, coalesce(i.name, v.name) AS item, sum(l.quantity) AS units ${SOLD}
87
+ GROUP BY i.id, item ORDER BY units DESC LIMIT 20`,
88
+ mapping: { x: "item", y: ["units"] },
89
+ clickThrough: {
90
+ object: "shop.variant",
91
+ filter: { field: "item", op: "eq", value: { $row: "item_id" } },
92
+ },
93
+ layout: { w: 12, h: 2 },
94
+ },
95
+ ],
96
+ };
97
+ export const shopDashboards = { shopOverview };